package com.snatch.work.service.impl.hg;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HTTP;
import org.apache.http.protocol.HttpContext;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONArray;
import com.snatch.common.constant.SnatchConstant;
import com.snatch.common.utils.SnatchConstantUtil;
import com.snatch.common.utils.StringUtils;
import com.snatch.common.vo.LiveMatch;
import com.snatch.common.vo.Matchinfo;
import com.snatch.common.vo.NodeTaskInput;
import com.snatch.common.vo.Playinfo;
import com.snatch.common.vo.RatioDataInput;
import com.snatch.common.vo.Result;
import com.snatch.common.vo.SnatchTask;
import com.snatch.common.vo.Sportinfo;
import com.snatch.common.vo.TradingItem;
import com.snatch.work.constant.HgConstant;
import com.snatch.work.service.SnatchService;
import com.snatch.work.utils.HttpUtil;
import com.snatch.work.utils.hg.HgUtil;
import com.snatch.work.vo.LoginData;
import com.snatch.work.vo.SnatchDataInput;
import com.snatch.work.vo.ThirdInfo;
import com.snatch.work.vo.hg.HgLoginVO;
import com.snatch.work.vo.hg.HgParamVO;
import com.snatch.work.vo.hg.HgSnatchPara;


/**
 * 皇冠抓取接口的实现类
 * 
 * @author TangLianfang
 * 
 */
@Service
public class HgSnatchDataImpl implements SnatchService {
	
	protected Logger logger = Logger.getLogger(HgSnatchDataImpl.class);
	
	private ExecutorService snatchExecutorService = Executors.newCachedThreadPool();// 抓取线程
	
	private ExecutorService gatherExecutorService = Executors.newCachedThreadPool();// 分析线程池
	
	private String showior="100"; // 显示位数
	private String iorpoints="2"; // 赔率小数点位数
	private String showtype="";
	
	@Override
	public void init(ThirdInfo thirdInfo) {
		/*rtype = findType(thirdInfo.getLoginData().getCrawlerWeb().getCollectName());*/
	}

	@Override
	public ThirdInfo connectionWeb(LoginData loginData) throws Exception {
		if (HttpUtil.isNull(loginData.getLoginAccount().getUserName()) || HttpUtil.isNull(loginData.getLoginAccount().getUserPwd())) {// 当用户名或密码为空时
			return null;
		}
		String url = loginData.getWebConfig().getUrl();
		DefaultHttpClient httpClient = HgUtil.getHttpClient(loginData);

		url = HttpUtil.dealHost(url);
		String path = url + "/app/member/";
		HttpGet httpGet = HttpUtil.getHttpGet(path);
		
		httpGet.addHeader("Host", HttpUtil.getPurceHost(url));
		httpGet.addHeader("Referer", url + "/");

		HttpContext localContext = new BasicHttpContext();
		HttpResponse response = HttpUtil.execute(httpClient, httpGet, localContext);
		String dataContext = HttpUtil.getHttpContext(response);

		//bobo 改成缓存登录失败则把该信息再日志
		logger.debug("获取第三方对象时网页相应的数据内容:\n" + dataContext);

		HgLoginVO hgLoginVO = new HgLoginVO();
		hgLoginVO.setLoginAccount(loginData.getLoginAccount());
		hgLoginVO.setProxy(loginData.getProxy());
		hgLoginVO.setWebConfig(loginData.getWebConfig());
		hgLoginVO.setHttpClient(httpClient);
		return hgLoginVO;
	}

	@Override
	public boolean refreshValidateCode(ThirdInfo thirdInfo) throws Exception {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public int login(ThirdInfo thirdInfo) throws Exception {
		if (null == thirdInfo || !(thirdInfo instanceof HgLoginVO)) {
			return SnatchConstant.FAIL;// 失败
		}
		HgLoginVO hgLoginVO = (HgLoginVO) thirdInfo;
		
		DefaultHttpClient httpClient = hgLoginVO.getHttpClient();
		if (null == httpClient) {
			return SnatchConstant.FAIL;// 失败
		}
		String url = HttpUtil.dealHost(hgLoginVO.getWebConfig().getUrl());// 第三方系统的url
		
		HttpGet httpGet = HttpUtil.getHttpGet(url);
		HttpContext localContext = new BasicHttpContext();
		HttpResponse response = HttpUtil.execute(httpClient, httpGet, localContext);
		String dataContext = HttpUtil.getHttpContext(response);
		
		//bobo 日志
		logger.debug("获取登录页面响应的网页数据:" + dataContext);

		if (dataContext.contains("System Maintenance")) {// 系统维护
			return SnatchConstant.LOGIN_FAIL_SYSTEM_MAINTENANCE;
		}

		// 登录链接post
		String loginUrl = url + "/app/member/login.php";

		// 获得登录页面的参数
		HttpPost httpPost = HttpUtil.getHttpPost(loginUrl);
		List<NameValuePair> nvps = new ArrayList<NameValuePair>();
		nvps.add(new BasicNameValuePair("uid", ""));
		nvps.add(new BasicNameValuePair("mac", ""));
		nvps.add(new BasicNameValuePair("ver", ""));
		nvps.add(new BasicNameValuePair("JE", "true"));
		nvps.add(new BasicNameValuePair("username", hgLoginVO.getLoginAccount().getUserName()));// 用户名
		nvps.add(new BasicNameValuePair("passwd", hgLoginVO.getLoginAccount().getUserPwd()));// 密码
		nvps.add(new BasicNameValuePair("langx", hgLoginVO.getWebConfig().getLangx()));// 简体版
		
		httpPost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));

		httpPost.addHeader("Host", HttpUtil.getPurceHost(url));
		httpPost.addHeader("Referer", url + "/app/member/");

		response = HttpUtil.execute(httpClient, httpPost, localContext);
		dataContext =HttpUtil.getHttpContext(response);

		logger.info("登录后响应的网页数据:" + dataContext);

		if (HttpUtil.isNull(dataContext)) {
			return SnatchConstant.FAIL;
		}

		// 用户名或密码错误
		if (dataContext.contains(SnatchConstant.WRONG_USERNAME_OR_PASSWORD_TEXT)) {
			return SnatchConstant.LOGIN_FAIL_WRONG_USERNAME_OR_PASSWORD;
		}
		// http://hg1088.com/app/member/account/chg_passwd.php?uid=45c1ed4m6445520l46596023&flag=3
		if (dataContext.contains("chg_passwd")) {// 该密码久未变更,为了安全起见,请先变更密码后再继续使用!
			return SnatchConstant.LOGIN_FAIL_CHANGE_PASSWORD;
		}

		String quote = "'";

		String uid = "";

		String keepAliveUrl = "";// 保持连接的url

		String formStr = "<form id='newdomain' action='";

		String signStr = "window.location.href = '";
		if (dataContext.contains(signStr)) {// 因不同的第三方系统url,在登录时响应的网页数据不一样,所以在此需作特殊处理
			dataContext = StringUtils.parseFormValue(dataContext, signStr, quote);
			//bobo 日志
			// http://hg1088.com/app/member/FT_index.php?mtype=3&uid=5b11d202m6445520l36715087&langx=zh-cn
			logger.info("截取后的dataContext is : " + dataContext);

			keepAliveUrl = dataContext;// 保持连接的url

			String uidStr = "&uid=";
			if (HttpUtil.isNull(dataContext) || !dataContext.contains(uidStr)) {
				return SnatchConstant.FAIL;
			}
			uid = StringUtils.parseFormValue(dataContext, uidStr, "&");
			logger.info("uid is :" + uid);

			// 获取跳转后的url
			logger.info(keepAliveUrl);
			httpGet = HttpUtil.getHttpGet(keepAliveUrl);
			httpGet.setHeader("Host", HttpUtil.getPurceHost(url));
			httpGet.setHeader("Referer", url + "/app/member/login.php");

			response = HttpUtil.execute(httpClient, httpGet, localContext);
			dataContext = HttpUtil.getHttpContext(response);
			logger.info("重新跳转后获取的内容：" + dataContext);

			uidStr = "action='";
			url = StringUtils.parseFormValue(dataContext, uidStr, quote);
			logger.info("跳转后的url: " + url);

			if (!HttpUtil.isNull(url)) {
				hgLoginVO.setUrl(url);
			}else{
				hgLoginVO.setUrl(thirdInfo.getWebConfig().getUrl());
			}
		} else if (dataContext.contains(formStr)) {
			//bobo
			logger.info("包含newdomain.");

			for (int i = 0; i < 2; i++) {
				url = StringUtils.parseFormValue(dataContext, formStr, quote);
				hgLoginVO.setUrl(url);

				uid = StringUtils.parseFormValue(dataContext, "<input type='hidden' name='uid' value='", quote);
				String mtype = StringUtils.parseFormValue(dataContext, "<input type='hidden' name='mtype' value='", quote);
				String today_gmt = StringUtils.parseFormValue(dataContext, "<input type='hidden' name='today_gmt' value='", quote);

				httpPost = HttpUtil.getHttpPost(url);

				nvps = new ArrayList<NameValuePair>();
				nvps.add(new BasicNameValuePair("uid", uid));
				nvps.add(new BasicNameValuePair("langx", hgLoginVO.getWebConfig().getLangx()));// 简体版
				nvps.add(new BasicNameValuePair("mtype", mtype));
				nvps.add(new BasicNameValuePair("today_gmt", today_gmt));

				httpPost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));

				response = HttpUtil.execute(httpClient, httpPost, localContext);
				dataContext = HttpUtil.getHttpContext(response);

				logger.debug(dataContext);

				String frameStr = "<frame name=\"SI2_mem_index\" src=\"";
				if (dataContext.contains(frameStr)) {
					url = StringUtils.parseFormValue(dataContext, frameStr, "\"");
				}

				keepAliveUrl = HttpUtil.dealHost(hgLoginVO.getUrl()) + "/" + url;// 保持连接的url

				httpPost = HttpUtil.getHttpPost(keepAliveUrl);

				response = HttpUtil.execute(httpClient, httpPost, localContext);
				dataContext = HttpUtil.getHttpContext(response);

				logger.debug(dataContext);

				if (dataContext.contains("<frame name=\"body\" src=\"")) {// 同一第三方系统url的不同用户登录跳转的次数不一致
					break;
				}
			}
		} else {
			return SnatchConstant.FAIL;
		}
		hgLoginVO.setUid(uid);
		hgLoginVO.setKeepAliveUrl(keepAliveUrl);// 添加保持连接的url
		hgLoginVO.setLoginTime(new Date());// 登录时间

		return SnatchConstant.SUCCESS;
	}

	@Override
	public int electSnatch(SnatchTask snatchTask) throws Exception {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public SnatchDataInput getData(NodeTaskInput nodeTaskInput,ThirdInfo thirdInfo) throws Exception {

		if (null == thirdInfo || !(thirdInfo instanceof HgLoginVO)) {
			return null;
		}
		HgLoginVO hgLoginVO = (HgLoginVO) thirdInfo;
		DefaultHttpClient httpClient = hgLoginVO.getHttpClient();
		if (null == httpClient) {
			return null;
		}
		/*// 参数初始化
		if (HttpUtil.isNull(showior) || HttpUtil.isNull(iorpoints)) {
			iniSiteParas(snatchTask,hgLoginVO);
		}*/
		
		long startParse = System.currentTimeMillis(); // 采集开始
		
		String [] contexts = getAllPageData(nodeTaskInput,thirdInfo);
		//bobo
		//logger.info(thirdInfo.getSeqNum()+"总抓取所耗时:"+(System.currentTimeMillis() - startParse));		
		
		SnatchDataInput snatchDataInput = new SnatchDataInput();
		snatchDataInput.setNodeTaskInput(nodeTaskInput);
		snatchDataInput.setUserName(thirdInfo.getLoginAccount().getUserName());
		snatchDataInput.setSnatchCost((System.currentTimeMillis() - startParse));
		snatchDataInput.setDatas(contexts);
		return snatchDataInput;
	}
	
	
	/**
	 * 获取所有分页数据
	 * @param thirdInfo
	 * @return
	 * @throws Exception
	 */
	private String [] getAllPageData(NodeTaskInput nodeTaskInput,ThirdInfo thirdInfo)throws Exception{
		int tempageCount = nodeTaskInput.getPage()>0?nodeTaskInput.getPage():1;
		CountDownLatch latch = new CountDownLatch(tempageCount);
		String [] pageResult = new String[tempageCount];
		long time = System.currentTimeMillis();
		for(int i=0;i<tempageCount;i++){
			try {
				SnatchWork work = new SnatchWork();
				work.init(nodeTaskInput,thirdInfo, pageResult,(tempageCount==1?0:i),latch);
				snatchExecutorService.execute(work);
			}catch (Exception e) {
				//bobo
				logger.error("获取数据分页数据获取失败："+" 唯标识："+nodeTaskInput.getOnlyCode()+" 用户名："+thirdInfo.getLoginAccount().getUserName(),e);
			}
		}
		try {
			if(0==latch.getCount()){
				logger.info("采集项:记数器值"+latch.getCount());
			}
			boolean excuteState = latch.await(HgConstant.MAXAWAIT,TimeUnit.SECONDS);
			//logger.info(" 采集项："+nodeTaskInput.getTaskCode()+" 结束："+(System.currentTimeMillis()-time));
			if(!excuteState){
				logger.info(nodeTaskInput.getOnlyCode()+"皇冠分页抓取超时，请查找原因！");
				//executorService = Executors.newFixedThreadPool(5);
			}
		} catch (InterruptedException e) {			
			e.printStackTrace();
		}
		if(pageResult.length!=tempageCount){
			logger.info(nodeTaskInput.getOnlyCode()+"抓取页数与网页显示页数不致");
		}
		return pageResult;
	}
	
	
	class SnatchWork implements Runnable {
		int pageNo;
		String [] pageResult;
		NodeTaskInput nodeTaskInput;
		ThirdInfo thirdInfo;
		CountDownLatch latch;
		public void init(NodeTaskInput nodeTaskInput,ThirdInfo thirdInfo, String [] pageResult,int pageNo,CountDownLatch latch){
			this.pageNo = pageNo;
			this.pageResult = pageResult;
			this.thirdInfo = thirdInfo;
			this.nodeTaskInput = nodeTaskInput;
			this.latch = latch;
		}
		
		@Override
		public void run() {
			try {
				 getPageData(nodeTaskInput,pageNo,pageResult,thirdInfo);
			} catch (Exception e) {
				logger.error("分页线程 SnatchWork：获取数据失败"+" 唯标识："+nodeTaskInput+" 用户名："+thirdInfo.getLoginAccount().getUserName(),e);
			}finally{
				latch.countDown();
			}
		}
		
	}
	
	

	/**
	 * 获取单面数据
	 * @param httpClient
	 * @param httpPost
	 * @param params
	 * @param pageNo
	 * @param pageResult
	 * @param thirdInfo
	 * @return -1 帳號登錄失敗 1 為成功
	 * @throws Exception
	 */
	public int getPageData(NodeTaskInput nodeTaskInput,int pageNo, String [] pageResult,
			ThirdInfo thirdInfo) throws Exception {
		HgLoginVO hgLoginVO = (HgLoginVO) thirdInfo;
		DefaultHttpClient defaultHttpClient = hgLoginVO.getHttpClient();
		String url = HttpUtil.dealHost(hgLoginVO.getUrl());

		/*		String param = "uid=" + hgLoginVO.getUid() + "&rtype=" + HgUtil.getSnatchType(snatchTask.getSnatchItem()) + "&langx=" + hgLoginVO.getLangx() + "&mtype=3";

		 * String tempUrl = "";
		String refererParam = "";
		if (collectName.equals(SnatchConstant.SOCCER_EARLY)) {// 早餐
			tempUrl = url + "/app/member/FT_future";
			refererParam = "&g_date=";
		} else {
			tempUrl = url + "/app/member/FT_browse";
			refererParam = "&delay=";
		}
		String snatchUrl = tempUrl + "/body_var.php";

		StringBuffer sb = new StringBuffer();
		sb.append("?").append(param);
		sb.append("&page_no=").append(String.valueOf(pageNo)); // 用本线程pageNo增加分页参数
		sb.append("&league_id=&hot_game=");
		if (collectName.equals(SnatchConstant.SOCCER_EARLY)) {// 早餐
			// TODO 目前暂时只获取提前一天的早盘赛事信息
			sb.append("&g_date=").append(HgUtil.getEarlyDateTime());// "ALL"全部,"0"特早,"yyyy-MM-dd"具体日期
			//sb.append("&g_date=").append("ALL");
		}*/
		
		
		HgParamVO hgParamvo = new HgParamVO();
		hgParamvo.setUrl(url);
		hgParamvo.setGameCode(nodeTaskInput.getGameCode());
		hgParamvo.setSnatchType(nodeTaskInput.getItemType());
		hgParamvo.setSnatchItem(nodeTaskInput.getItemName());
		hgParamvo.setUid(hgLoginVO.getUid());
		hgParamvo.setLangx(hgLoginVO.getWebConfig().getLangx());
		hgParamvo.setPage_no(pageNo);
		
		if(SnatchConstant.HG_SNATCH_ITEM_FIRST.equals(nodeTaskInput.getItemName())){
			if(hgLoginVO.getMid() == null || "".equals(hgLoginVO.getMid())){
				findmid(nodeTaskInput,thirdInfo);
			}
			if(hgLoginVO.getMid() == null || "".equals(hgLoginVO.getMid())) return -1;
			hgParamvo.setMid(hgLoginVO.getMid());
		}
		
		hgParamvo.setUrltype(0);
		String snatchUrl = HgUtil.getSnatchUrl(hgParamvo);
		hgParamvo.setUrltype(1);
		String refererUrl = HgUtil.getSnatchUrl(hgParamvo);

		//logger.debug("第" + (pageNo + 1) + "页带参数的snatchUrl = " + snatchUrl);

		HttpGet httpGet = HttpUtil.getHttpGet(snatchUrl);

		httpGet.addHeader("Host", HttpUtil.getPurceHost(url));
		httpGet.addHeader("Referer", refererUrl);
		
		
		//过滤不抓取的
		if(!thirdInfo.isValid()){
			return -1;
		}
		HttpContext localContext = new BasicHttpContext();
		HttpResponse response = HttpUtil.execute(defaultHttpClient, httpGet, localContext);

/*		String snatchTime = HttpUtil.dealSnatchTime(response.getFirstHeader("Date").getValue());// 抓取时间戳为GMT
*/
		//logger.debug("抓取时间戳：" + snatchTime);

		String dataContext = HttpUtil.getHttpContext(response);
		//logger.info("第" + (pageNo + 1) + "页,抓取耗时:" + (System.currentTimeMillis() - startTime));
		
		//bobo

		/*long seqNum = hgLoginVO.getSeqNum();

		SnatchLog.log(SnatchConstant.THIRD_SYSTEM_HG_TEXT, collectName, "第" + seqNum + "次抓取所使用的账号是:" + userName + ",第" + (pageNo + 1) + "页响应的网页数据内容:\n" + dataContext);
		if (SnatchConstant.SOCCER_GQ.equals(collectName)) {
			SnatchLog.logLive(SnatchConstant.THIRD_SYSTEM_HG_TEXT, "第" + seqNum + "次抓取所使用的账号是:" + userName + ",第" + (pageNo + 1) + "页响应的网页数据内容:\n" + dataContext);
		}*/

		// <script>window.open('http://hg1088.com/tpl/logout_warn.html','_top')</script>
		if (HttpUtil.isNull(dataContext) || dataContext.contains("logout_warn.html")
				|| dataContext.contains("<input type='hidden' name='chghasLogin' value='login'>")) {
			thirdInfo.setValid(false);
			thirdInfo.setWhyValid(SnatchConstant.ERROR_USER_LOGOUT);
			if(!HttpUtil.isNull(dataContext)){
				logger.info("被登出！原因是："+dataContext);
			}else{
				logger.info("被登出！原因是数据为空");
			}
			return -1;
		}
		if(dataContext.contains(HgConstant.PARENT_CLEAN_DATA_Y)){
			nodeTaskInput.setMaintenType(1);
			return -1;
		}

		pageResult[pageNo] = dataContext;
		return 0;
	}
	
	public void findmid(NodeTaskInput nodeTaskInput,ThirdInfo thirdInfo)throws Exception{
		HgLoginVO hgLoginVO = (HgLoginVO) thirdInfo;
		DefaultHttpClient httpClient = hgLoginVO.getHttpClient();
		String url = HttpUtil.dealHost(hgLoginVO.getUrl());
		HgParamVO hgParamvo = new HgParamVO();
		hgParamvo.setUrl(url);
		hgParamvo.setGameCode(nodeTaskInput.getGameCode());
		hgParamvo.setSnatchType(nodeTaskInput.getItemType());
		hgParamvo.setSnatchItem(SnatchConstant.HG_SNATCH_ITEM_FIRST_LOAD);
		hgParamvo.setUid(hgLoginVO.getUid());
		hgParamvo.setLangx(hgLoginVO.getWebConfig().getLangx());
		
		
		hgParamvo.setUrltype(0);
		String snatchUrl = HgUtil.getSnatchUrl(hgParamvo);
		hgParamvo.setUrltype(1);
		String refererUrl = HgUtil.getSnatchUrl(hgParamvo);
		
		HttpGet httpGet = HttpUtil.getHttpGet(snatchUrl);
		httpGet.addHeader("Host", HttpUtil.getPurceHost(url));
		httpGet.addHeader("Referer", refererUrl);
		
		//过滤不抓取的
		if(!thirdInfo.isValid()){
			return;
		}
		HttpContext localContext = new BasicHttpContext();
		HttpResponse response = HttpUtil.execute(httpClient, httpGet, localContext);

		String dataContext = HttpUtil.getHttpContext(response);
		if(null != dataContext){
			String mid =  StringUtils.parseFormValue(dataContext, HgConstant.PARENT_MID, HgConstant.PARENT_MID_END);
			hgLoginVO.setMid(mid);
		}
	}
	
	
	@Override
	public SnatchDataInput getUpdateData(ThirdInfo thirdInfo,
			String collectCode, String updateTime) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public RatioDataInput gatherData(SnatchDataInput snatchDataInput) {
		long tiem = System.currentTimeMillis();
		String[] datas = snatchDataInput.getDatas();
		List<Sportinfo> sportinfos = new ArrayList<Sportinfo>();
		List<Sportinfo> [] pageResult = new ArrayList[datas.length];
		HgSnatchPara hgSnatchPara = parseSnatchPara(datas[0]);
		CountDownLatch latch = new CountDownLatch(datas.length);
		
		
		for(int i=0;i<datas.length;i++){
			try {
				GatherWork work = new GatherWork();
				work.init(snatchDataInput.getNodeTaskInput(), pageResult,datas[i],i,latch);
				gatherExecutorService.execute(work);
			}catch (Exception e) {
				//bobo
				logger.error("获取数据分页数据获取失败："+" 唯标识："+snatchDataInput.getNodeTaskInput().getOnlyCode()+" 用户名："+snatchDataInput.getNodeTaskInput().getItemName(),e);
			}
		}
		try {
			boolean excuteState = latch.await(HgConstant.MAXAWAIT,TimeUnit.SECONDS);
			if(!excuteState){
				logger.info(snatchDataInput.getNodeTaskInput()+"皇冠分页抓取超时，请查找原因！");
				//executorService = Executors.newFixedThreadPool(5);
			}
		} catch (InterruptedException e) {			
			e.printStackTrace();
		}
		
		
		for(List<Sportinfo> list : pageResult){
			if(null !=list){
				sportinfos.addAll(list);
			}
		}
		sportinfos = bineSportinfo(sportinfos);
		//logger.info(snatchDataInput.getNodeTaskInput().getTaskCode()+"解析赛事成功："+(System.currentTimeMillis()-tiem));
		RatioDataInput ratioDataInput = new RatioDataInput();
		if(null !=hgSnatchPara){
			ratioDataInput.setSumPage(hgSnatchPara.getT_page());
		}
		ratioDataInput.setSportinfos(sportinfos);
		return ratioDataInput;
	}
	

	class GatherWork implements Runnable {
		List<Sportinfo> [] pageResult;
		NodeTaskInput nodeTaskInput;
		String dataContext;
		CountDownLatch latch;
		int index;
		public void init(NodeTaskInput nodeTaskInput, List<Sportinfo> [] pageResult,String dataContext,int index,CountDownLatch latch){
			this.pageResult = pageResult;
			this.nodeTaskInput = nodeTaskInput;
			this.dataContext = dataContext;
			this.index = index;
			this.latch = latch;
		}
		
		@Override
		public void run() {
			try {
				List<Sportinfo> list = null;
				 if(SnatchConstant.HG_SNATCH_ITEM_RESULT.equals(nodeTaskInput.getItemName())){
					 list = parseResult(nodeTaskInput,dataContext);
				 }else{
					 list = parseMatch(nodeTaskInput,dataContext);
				 }
				 pageResult[index] = list;
			} catch (Exception e) {
				logger.error("分页线程 SnatchWork：获取数据失败"+" 唯标识："+nodeTaskInput,e);
			}finally{
				latch.countDown();
			}
		}
		
	}
	
	
	public HgSnatchPara parseSnatchPara(String dataContext){
		if(null == dataContext) return null;
		HgSnatchPara hgSnatchPara = new HgSnatchPara();
		if (dataContext.contains(HgConstant.PARENT_GAMOUNT)) {
			hgSnatchPara.setGamount(StringUtils.parseFormValue(dataContext, HgConstant.PARENT_GAMOUNT, HgConstant.PARENT_QUOTE)) ;
		}
		if (dataContext.contains(HgConstant.PARENT_T_PAGE)) {
			hgSnatchPara.setT_page(StringUtils.parseFormInteger(dataContext, HgConstant.PARENT_T_PAGE, HgConstant.PARENT_QUOTE)) ;
		}
		
		if (dataContext.contains(HgConstant.TOP_TODAY_GMT)) {
			hgSnatchPara.setToday_gmt(StringUtils.parseFormValue(dataContext, HgConstant.TOP_TODAY_GMT, HgConstant.PARENT_TIME_QUOTE)) ;
		}
		if (dataContext.contains(HgConstant.TOP_NOW_GMT)) {
			hgSnatchPara.setNow_gmt(StringUtils.parseFormValue(dataContext, HgConstant.TOP_NOW_GMT, HgConstant.PARENT_TIME_QUOTE)) ;
		}
		return hgSnatchPara;
	}
	
	/**
	 *  解析单个页面抓取的数据
	 * @return
	 */
	public List<Sportinfo> parseMatch(NodeTaskInput nodeTaskInput,String dataContext)throws Exception{
		List<Sportinfo> sportinfos = new ArrayList<Sportinfo>();// 联赛列表
		if(dataContext==null) return sportinfos;
		Map<String,Sportinfo> sportinfomap = new HashMap<String,Sportinfo>();
		List<Object> jsonArrays = null;
		if(SnatchConstant.HG_SNATCH_ITEM_FIRST.equals(nodeTaskInput.getItemName())){
			jsonArrays = findJsonDataFirst(dataContext);
		}else{
			jsonArrays = findJsonData(dataContext);
		}
		List<Object> newList = new ArrayList<Object>();
		newList.addAll(jsonArrays);
		String snatchTime = HgUtil.hgSnatchTime(dataContext);//HttpUtil.getJsonArrayStringValue(lineArray, snatchTimeArray);
		// 联赛set
		if (null != newList && newList.size() > 0) {
			JSONArray lineArray = null;
			for (Object obj : newList) {
				lineArray = (JSONArray) obj;
				Sportinfo sportinfo = null;// 联赛信息
				String leagueName = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_LEAGUE_NAME);
				Sportinfo temsportinfo = findSportinfo(leagueName);
				if(!sportinfomap.containsKey(temsportinfo.getSelfID())){
					sportinfomap.put(temsportinfo.getSelfID(), temsportinfo);
					sportinfo = temsportinfo;
				}else{
					sportinfo = sportinfomap.get(temsportinfo.getSelfID());
				}
				// 赛事信息
				Matchinfo match = null;
				if(SnatchConstant.HG_SNATCH_ITEM_FIRST.equals(nodeTaskInput.getItemName())){
					match = findMatchinfoFirst(nodeTaskInput, temsportinfo, lineArray, snatchTime);
				}else{
					match = findMatchinfo(nodeTaskInput, sportinfo, lineArray, snatchTime);
				}
				List<Playinfo> playinfos = null;// 玩法列表
				// 判断玩法列表是否存在
				if (null != match.getPlayinfos()) {
					playinfos = match.getPlayinfos();// 存在,就使用原来的玩法对象
				} else {
					playinfos = new ArrayList<Playinfo>();// 不存在则创建
				}
				
				if(SnatchConstant.FOOTBALL.equals(nodeTaskInput.getGameCode())){
					if (SnatchConstant.HG_SNATCH_ITEM_STANDARD.equals(nodeTaskInput.getItemName())) {
						match.setPlayinfos(parseStandardOddsData(playinfos, lineArray,nodeTaskInput.getGameCode(),nodeTaskInput.getItemType(), nodeTaskInput.getRatioType(), showior, iorpoints));
					} else if (SnatchConstant.HG_SNATCH_ITEM_TG.equals(nodeTaskInput.getItemName())) {
						match.setPlayinfos(parseTGOddsData(playinfos, lineArray,nodeTaskInput.getItemType()));
					} else if (SnatchConstant.HG_SNATCH_ITEM_HT_FT.equals(nodeTaskInput.getItemName())) {
						match.setPlayinfos(parseHTFTOddsData(playinfos, lineArray));
					} else if (SnatchConstant.HG_SNATCH_ITEM_FTCS.equals(nodeTaskInput.getItemName()) || SnatchConstant.HG_SNATCH_ITEM_HF_FTCS.equals(nodeTaskInput.getItemName())) {
						match.setPlayinfos(parseCSOddsData(nodeTaskInput.getItemName(),playinfos, lineArray));
					}else if(SnatchConstant.HG_SNATCH_ITEM_PASS.equals(nodeTaskInput.getItemName())){
						match.setPlayinfos(parsePASSOddsData(playinfos,nodeTaskInput.getGameCode(),nodeTaskInput.getItemType(), lineArray, nodeTaskInput.getRatioType(), showior, iorpoints));
					}else if(SnatchConstant.HG_SNATCH_ITEM_FIRST.equals(nodeTaskInput.getItemName())){
						match.setPlayinfos(parseFIRSTOddsData(playinfos, lineArray, nodeTaskInput.getRatioType(), showior, iorpoints));
					}
				}else{
					if (SnatchConstant.HG_SNATCH_ITEM_STANDARD.equals(nodeTaskInput.getItemName())) {
						match.setPlayinfos(parseStandardOddsData(playinfos, lineArray,nodeTaskInput.getGameCode(),nodeTaskInput.getItemType(), nodeTaskInput.getRatioType(), showior, iorpoints));
					}else if(SnatchConstant.HG_SNATCH_ITEM_PASS.equals(nodeTaskInput.getItemName())){
						match.setPlayinfos(parsePASSOddsData(playinfos,nodeTaskInput.getGameCode(),nodeTaskInput.getItemType(), lineArray, nodeTaskInput.getRatioType(), showior, iorpoints));
					}else if(SnatchConstant.HG_SNATCH_ITEM_FIRST.equals(nodeTaskInput.getItemName())){
						match.setPlayinfos(parseFIRSTOddsData(playinfos, lineArray, nodeTaskInput.getRatioType(), showior, iorpoints));
					}
				}
					
					
				
			}
		}
		sportinfos.addAll(sportinfomap.values());
		return sportinfos;
	}
	
	

	/**
	 *  解析单个页面抓取的数据
	 * @return
	 */
	public List<Sportinfo> parseResult(NodeTaskInput nodeTaskInput,String dataContext)throws Exception{
		List<Sportinfo> sportinfos = new ArrayList<Sportinfo>();// 联赛列表
		if(dataContext==null) return sportinfos;
		if(SnatchConstant.FOOTBALL.equals(nodeTaskInput.getGameCode())){
			sportinfos = parseFootBallResult(nodeTaskInput, dataContext);
		}else if(SnatchConstant.BASKETBALL.equals(nodeTaskInput.getGameCode())){
			sportinfos = parseBasketBallResult(nodeTaskInput, dataContext);
		}
		return sportinfos;
	}
	
	/**
	 * 足球赛果解析
	 * @param nodeTaskInput
	 * @param dataContext
	 * @return
	 * @throws Exception
	 */
	public List<Sportinfo> parseFootBallResult(NodeTaskInput nodeTaskInput,String dataContext) throws Exception{
		List<Sportinfo> sportinfos = new ArrayList<Sportinfo>();// 联赛列表
		if(dataContext.contains(HgConstant.PARENT_FIRST_RESULT)){
			InputStream is = new ByteArrayInputStream(dataContext.toString().getBytes());
			BufferedReader reader = new BufferedReader(new InputStreamReader(is));
			Sportinfo sprtinfo = null;
			Result result = null;
			String hostName = null;
			String awayName = null;
			String startTime = null;
			
			for (String line = reader.readLine(); null != line; line = reader.readLine()) {
				line = line.trim();
				if (line.contains(HgConstant.PARENT_FIRST_RESULT)) {
					String leagueName = StringUtils.parseFormValue(line, HgConstant.PARENT_FIRST_RESULT,  HgConstant.PARENT_END_LEAGUE);
					sprtinfo = findSportinfo(leagueName);
					sportinfos.add(sprtinfo);
				}else if(line.contains(HgConstant.PARENT_TIME_FIRST)){
					startTime =  StringUtils.parseFormValue(line, HgConstant.PARENT_TIME_FIRST,  HgConstant.PARENT_TIME_END);
					if(startTime.contains("a") || startTime.contains("p")){
						startTime = HgUtil.dealStartTime(startTime, nodeTaskInput.getItemType());
					}
				}else if(line.contains(HgConstant.PARENT_GAMECOUNT_MATCH)){
					hostName =  StringUtils.parseFormValue(line, HgConstant.PARENT_HOST_FIRST_MATCH,  HgConstant.PARENT_HOST_END_MATCH);
					hostName = StringUtils.replace("&nbsp;", "", hostName);
					hostName = hostName.trim();
				}else if(line.contains(HgConstant.PARENT_AWAY_FIRST_MATCH)){
					awayName =  StringUtils.parseFormValue(line, HgConstant.PARENT_AWAY_FIRST_MATCH,  HgConstant.PARENT_AWAY_END_MATCH);
					awayName = StringUtils.replace("&nbsp;", "", awayName);
					awayName = awayName.trim();
					String matchName = hostName + SnatchConstant.VS + awayName;
					String matchselfID = SnatchConstantUtil.foundSelid("", matchName, SnatchConstant.THIRD_SYSTEM_HG_VALUE);
					result = new Result();
					result.setTarget(nodeTaskInput.getWebCode());
					result.setGameCode(nodeTaskInput.getGameCode());
					result.setLeagueSelfid(sprtinfo.getSelfID());
					result.setLeagueName(sprtinfo.getName());
					result.setMatchSelfid(matchselfID);
					result.setMatchName(matchName);
					result.setStartTime(startTime);
					sprtinfo.getResults().add(result);
				}else if(line.contains(HgConstant.PARENT_HR_GAMECOUNT_GOAL)){
					String hhtGoalstr = StringUtils.parseFormValue(line, HgConstant.PARENT_HR_FIRST_GOAL,  HgConstant.PARENT_HR_END_GOAL);
					int hhtGoal = 0;
					if(StringUtils.isNumeric(hhtGoalstr)){
						hhtGoal = Integer.valueOf(hhtGoalstr);
					}else{
						result.setMatchError(hhtGoalstr);
					}
					result.setHhtGoal(hhtGoal);
					line = reader.readLine();
					
					String hatGoalstr = StringUtils.parseFormValue(line, HgConstant.PARENT_HR_FIRST_GOAL,  HgConstant.PARENT_HR_END_GOAL);
					int ahtGoal = 0;
					if(StringUtils.isNumeric(hatGoalstr)){
						ahtGoal = Integer.valueOf(hatGoalstr);
					}
					result.setHatGoal(ahtGoal);
					
				}else if(line.contains(HgConstant.PARENT_FULL_GAMECOUNT_GOAL)){
					
					String htGoalstr = StringUtils.parseFormValue(line, HgConstant.PARENT_FULL_FIRST_GOAL,  HgConstant.PARENT_FULL_END_GOAL);
					int htGoal = 0;
					if(StringUtils.isNumeric(htGoalstr)){
						htGoal = Integer.valueOf(htGoalstr);
					}else{
						result.setMatchError(htGoalstr);
					}
					result.setHhtGoal(htGoal);
					line = reader.readLine();
					
					String atGoalstr = StringUtils.parseFormValue(line, HgConstant.PARENT_FULL_FIRST_GOAL,  HgConstant.PARENT_FULL_END_GOAL);
					int aGoal = 0;
					if(StringUtils.isNumeric(atGoalstr)){
						aGoal = Integer.valueOf(atGoalstr);
					}
					result.setAwayGoal(aGoal);
				}
				
			}
		}
		
		return sportinfos;
	}
	
	
	public List<Sportinfo> parseBasketBallResult(NodeTaskInput nodeTaskInput,String dataContext) throws Exception{
		List<Sportinfo> sportinfos = new ArrayList<Sportinfo>();// 联赛列表
		if(dataContext.contains(HgConstant.PARENT_FIRST_RESULT)){
			InputStream is = new ByteArrayInputStream(dataContext.toString().getBytes());
			BufferedReader reader = new BufferedReader(new InputStreamReader(is));
			Sportinfo sprtinfo = null;
			Result result = null;
			String hostName = null;
			String awayName = null;
			String startTime = null;
			boolean comment = false;
			for (String line = reader.readLine(); null != line; line = reader.readLine()) {
				line = line.trim();
				//注释代码存在 并注释代码结束不存在 则代码注释 comment = true;
				if(line.contains(HgConstant.PARENT_COMMENT_FIRST) && !line.contains(HgConstant.PARENT_COMMENT_END)){
					comment = true;
				}else if(line.contains(HgConstant.PARENT_COMMENT_END)){
					comment = false;
				}
				
				if(comment){
					continue;
				}
				
				if (line.contains(HgConstant.PARENT_FIRST_RESULT)) {
					if(sprtinfo!=null){
						sportinfos.add(sprtinfo);
					}
					String leagueName = StringUtils.parseFormValue(line, HgConstant.PARENT_FIRST_RESULT,  HgConstant.PARENT_END_LEAGUE);
					sprtinfo = findSportinfo(leagueName);
				}else if(line.contains(HgConstant.PARENT_TIME_FIRST)){
					startTime =  StringUtils.parseFormValue(line, HgConstant.PARENT_TIME_FIRST,  HgConstant.PARENT_TIME_END);
					if(startTime.contains("a") || startTime.contains("p")){
						startTime = HgUtil.dealStartTime(startTime, nodeTaskInput.getItemType());
					}
				}else if(line.contains(HgConstant.PARENT_HOST_FIRST_MATCH_BASKET)){
					hostName =  StringUtils.parseFormValue(line, HgConstant.PARENT_HOST_FIRST_MATCH_BASKET,  HgConstant.PARENT_TD_END_MATCH_BASKET);
					hostName = StringUtils.replace("&nbsp;", "", hostName);
					hostName = hostName.trim();
				}else if(line.contains(HgConstant.PARENT_AWAY_FIRST_MATCH_BASKET)){
					awayName =  StringUtils.parseFormValue(line, HgConstant.PARENT_AWAY_FIRST_MATCH_BASKET,  HgConstant.PARENT_TD_END_MATCH_BASKET);
					awayName = StringUtils.replace("&nbsp;", "", awayName);
					awayName = awayName.trim();
					String matchName = hostName + SnatchConstant.VS + awayName;
					String matchselfID = SnatchConstantUtil.foundSelid("", matchName, SnatchConstant.THIRD_SYSTEM_HG_VALUE);
					result = new Result();
					result.setTarget(nodeTaskInput.getWebCode());
					result.setGameCode(nodeTaskInput.getGameCode());
					result.setLeagueSelfid(sprtinfo.getSelfID());
					result.setLeagueName(sprtinfo.getName());
					result.setMatchSelfid(matchselfID);
					result.setMatchName(matchName);
					result.setStartTime(startTime);
					sprtinfo.getResults().add(result);
				}else if(line.contains(HgConstant.PARENT_PITCH_FIRST_GOAL)){
					int pitch = StringUtils.parseFormNumeric(line, HgConstant.PARENT_PITCH_FIRST_GOAL, HgConstant.PARENT_PITCH_END_GOAL);
					if(0!=pitch){
						Integer hGoal=0,aGoal=0;
						line = reader.readLine();
						if(line!=null){
							hGoal = StringUtils.parseFormNumeric(line, HgConstant.PARENT_STRONG_FIRST_GOAL,  HgConstant.PARENT_STRONG_END_GOAL);
						}
						line = reader.readLine();
						if(line!=null){
							aGoal = StringUtils.parseFormNumeric(line, HgConstant.PARENT_STRONG_FIRST_GOAL,  HgConstant.PARENT_STRONG_END_GOAL);
						}
						switch (pitch) {
						case 1:
							result.setOnehGoal(hGoal);
							result.setOneaGoal(aGoal);
							break;
						case 2:
							result.setTwohGoal(hGoal);
							result.setTwoaGoal(aGoal);
							break;
						case 3:
							result.setThreehGoal(hGoal);
							result.setThreeaGoal(aGoal);
							break;
						case 4:
							result.setFourhGoal(hGoal);
							result.setFouraGoal(aGoal);
							break;
						default:
							break;
						}
					}
				}else if(line.contains(HgConstant.PARENT_FH_GAMECOUNT_GOAL)){
					Integer hGoal=0,aGoal=0;
					line = reader.readLine();
					if(line!=null){
						hGoal = StringUtils.parseFormNumeric(line, HgConstant.PARENT_FS_FIRST_GOAL,  HgConstant.PARENT_TD_END_MATCH_BASKET);
					}
					line = reader.readLine();
					if(line!=null){
						aGoal = StringUtils.parseFormNumeric(line, HgConstant.PARENT_FS_FIRST_GOAL,  HgConstant.PARENT_TD_END_MATCH_BASKET);
					}
					if(null != hGoal && null != aGoal){
						result.setHhtGoal(hGoal);
						result.setHatGoal(aGoal);
					}
				}else if(line.contains(HgConstant.PARENT_SH_GAMECOUNT_GOAL)){
					Integer hGoal=0,aGoal=0;
					line = reader.readLine();
					if(line!=null){
						hGoal = StringUtils.parseFormNumeric(line, HgConstant.PARENT_FS_FIRST_GOAL,  HgConstant.PARENT_TD_END_MATCH_BASKET);
					}
					line = reader.readLine();
					if(line!=null){
						aGoal = StringUtils.parseFormNumeric(line, HgConstant.PARENT_FS_FIRST_GOAL,  HgConstant.PARENT_TD_END_MATCH_BASKET);
					}
					result.setShrhGoal(hGoal);
					result.setShraGoal(aGoal);
					
				}else if(line.contains(HgConstant.PARENT_ET_GAMECOUNT_GOAL)){
					Integer hGoal=0,aGoal=0;
					line = reader.readLine();
					if(line!=null){
						hGoal = StringUtils.parseFormNumeric(line, HgConstant.PARENT_STRONG_FIRST_GOAL,  HgConstant.PARENT_STRONG_END_GOAL);
					}
					line = reader.readLine();
					if(line!=null){
						aGoal = StringUtils.parseFormNumeric(line, HgConstant.PARENT_STRONG_FIRST_GOAL,  HgConstant.PARENT_STRONG_END_GOAL);
					}
					if(null != hGoal && null != aGoal){
						result.setEthGoal(hGoal);
						result.setEtaGoal(aGoal);
					}
				}else if(line.contains(HgConstant.PARENT_FU_GAMECOUNT_GOAL)){
					Integer hGoal=0,aGoal=0;
					
					String hGoalstr = StringUtils.parseFormValue(line, HgConstant.PARENT_FU_FIRST_GOAL,  HgConstant.PARENT_TD_END_MATCH_BASKET);
					if(StringUtils.isNumeric(hGoalstr)){
						hGoal = Integer.valueOf(hGoalstr);
					}else{
						result.setMatchError(hGoalstr);
					}
					line = reader.readLine();
					
					String aGoalstr = StringUtils.parseFormValue(line, HgConstant.PARENT_FU_FIRST_GOAL,  HgConstant.PARENT_TD_END_MATCH_BASKET);
					if(StringUtils.isNumeric(aGoalstr)){
						aGoal = Integer.valueOf(aGoalstr);
					}else{
						result.setMatchError(hGoalstr);
					}
					
					result.setHatGoal(hGoal);
					result.setAwayGoal(aGoal);
				}
				
			}
		}
		
		return sportinfos;
	}
	
	
	private Sportinfo findSportinfo(String leagueName){
		Sportinfo sportinfo = new Sportinfo();
		leagueName = HttpUtil.dealName(leagueName);// 去掉联赛中所有的空格
		String leagueSelfID = SnatchConstantUtil.foundSelid("", leagueName, SnatchConstant.THIRD_SYSTEM_HG_VALUE);//HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_LEAGUE_ID);//
		sportinfo.setSelfID(leagueSelfID);
		// 设置联赛信息
		sportinfo.setName(leagueName);// 联赛名称
		return sportinfo;
	}
	private Matchinfo findMatchinfo(NodeTaskInput nodeTaskInput,Sportinfo sportinfo,JSONArray lineArray,String snatchTime){
		// 赛事信息
		Matchinfo match = null;
		
		Integer[] PASS_NUMBER = null;
		Integer[] START_TIME = null;
		if(SnatchConstant.HG_SNATCH_ITEM_STANDARD.equals(nodeTaskInput.getItemName())){
			if (SnatchConstant.SNATCH_TYPE_GQ.equals(nodeTaskInput.getItemType())) {
				if(SnatchConstant.TENNIS.equals(nodeTaskInput.getGameCode())){
					START_TIME =  HgConstant.TENNIS_MATCH_START_TIME_STANDARD_GQ;
				}else if(SnatchConstant.VOLLEYBALL.equals(nodeTaskInput.getGameCode())){
					START_TIME =  HgConstant.VOLLEYBALL_MATCH_START_TIME_STANDARD_GQ;
				}else if(SnatchConstant.OTHER.equals(nodeTaskInput.getGameCode())){
					START_TIME =  HgConstant.OTHER_MATCH_START_TIME_STANDARD_GQ;
				}else{
					START_TIME =  HgConstant.ARRAY_MATCH_START_TIME_STANDARD_GQ;
				}
			} else {
				START_TIME =  HgConstant.ARRAY_MATCH_START_TIME_STANDARD_SP;
			}
		}
		
		if(SnatchConstant.HG_SNATCH_ITEM_PASS.equals(nodeTaskInput.getItemName())){
			if(SnatchConstant.FOOTBALL.equals(nodeTaskInput.getGameCode())){
				PASS_NUMBER = HgConstant.PASS_PLAY_TYPE_ALL_NUMBER;
			}else if(SnatchConstant.BASKETBALL.equals(nodeTaskInput.getGameCode())){
				PASS_NUMBER = HgConstant.BASKETBALL_PLAY_TYPE_ALL_NUMBER;
			}else if(SnatchConstant.TENNIS.equals(nodeTaskInput.getGameCode())){
				PASS_NUMBER = HgConstant.TENNIS_PLAY_TYPE_ALL_NUMBER;
			}else if(SnatchConstant.VOLLEYBALL.equals(nodeTaskInput.getGameCode())){
				PASS_NUMBER = HgConstant.TENNIS_PLAY_TYPE_ALL_NUMBER;
			}
		}
		
		
		
		
		
		// 获取赛事主队名称
		String hostName = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_MATCH_HOST_NAME);
		hostName = HttpUtil.blockingName(hostName, HgConstant.PARENT_MATCH_FONT, HgConstant.PARENT_MATCH_FONT);
		hostName = HttpUtil.dealName(hostName);// 去掉赛事主队名称中所有的空格
		// 获取赛事客队名称
		String awayName = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_MATCH_CUSTOMER_NAME);
		awayName = HttpUtil.blockingName(awayName, HgConstant.PARENT_MATCH_FONT, HgConstant.PARENT_MATCH_FONT);
		awayName = HttpUtil.dealName(awayName);// 去掉赛事客队名称中所有的空格
		/*
		String hostid = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_MATCH_HOST_ID);
		hostid = HttpUtil.dealName(hostid);// 去掉赛事主队名称中所有的空格
		// 获取赛事客队名称
		String awayid = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_MATCH_CUSTOMER_ID);
		awayid = HttpUtil.dealName(awayid);// 去掉赛事客队名称中所有的空格
		
		String matchName = hostName + SnatchConstant.VS + awayName; 
		String matchselfID = hostid+"_"+awayid;*/
		// 组合,即得:赛事名称
		String matchName = hostName + SnatchConstant.VS + awayName;
		String matchselfID = SnatchConstantUtil.foundSelid("", matchName, SnatchConstant.THIRD_SYSTEM_HG_VALUE);
		// 判断赛事是否存在
		if (null != sportinfo.getMatchs()) {
			for (Matchinfo mat : sportinfo.getMatchs()) {
				if (mat.getMatchselfID().equals(matchselfID)) {
					return mat;
				}
			}
		}
		match = new Matchinfo();
		// 获取赛事开赛时间
		String startTime = "";
		if(null != START_TIME){
			startTime = HttpUtil.getJsonArrayStringValue(lineArray, START_TIME);
		}
		startTime = HgUtil.dealStartTime(startTime, nodeTaskInput.getItemType());
		if(null != PASS_NUMBER){
			match.setBunch(true);
			match.setBunchNumber(HttpUtil.getJsonArrayIntValue(lineArray, PASS_NUMBER));
		}
		// 设置赛事信息
		match.setMatchselfID(matchselfID);
		match.setMatchName(matchName);// 赛事名称*/
/*		match.setHostid(hostid);
		match.setHostName(hostName);
		match.setAwayid(awayid);
		match.setAwayName(awayName);*/
		match.setMatchType(nodeTaskInput.getItemType());
		match.setStartTime(startTime);// 开赛时间"yyyy-MM-dd hh24:mm:ss"
		match.setSnatchTime(snatchTime);// 抓取时间戳"yyyy-MM-dd hh24:mm:ss"

		if (SnatchConstant.SNATCH_TYPE_GQ.equals(nodeTaskInput.getItemType()) && SnatchConstant.HG_SNATCH_ITEM_STANDARD.equals(nodeTaskInput.getItemName())) {
			LiveMatch liveMatch = null;
			if(SnatchConstant.FOOTBALL.equals(nodeTaskInput.getGameCode())){
				liveMatch = findFootballLiveMatch(lineArray);
			}else if(SnatchConstant.BASKETBALL.equals(nodeTaskInput.getGameCode())){
				liveMatch = findBasketballLiveMatch(lineArray);
			}else if(SnatchConstant.TENNIS.equals(nodeTaskInput.getGameCode())){
				liveMatch = findIennisLiveMatch(lineArray);
			}else if(SnatchConstant.VOLLEYBALL.equals(nodeTaskInput.getGameCode())){
				liveMatch = findVolleyballLiveMatch(lineArray);
			}else if(SnatchConstant.OTHER.equals(nodeTaskInput.getGameCode())){
				liveMatch = findOtherLiveMatch(lineArray);
			}
			
			liveMatch.setLeagueSelfID(sportinfo.getSelfID());
			liveMatch.setLeagueName(sportinfo.getName());
			liveMatch.setMatchSelfID(matchselfID);
			liveMatch.setMatchName(matchName);
			liveMatch.setSystemTime(snatchTime);// 系统时间
			match.setLiveMatch(liveMatch);// 加入盘中信息
		}
		sportinfo.getMatchs().add(match);
		return match;
	}
	
	
	private LiveMatch findFootballLiveMatch(JSONArray lineArray){
		// 显示时间(已开赛时间)
		String showTime = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_LIVE_MATCH_PLAYED_TIME);
		// 小节信息 0为中场,1为上半场,2为下半场
		int status = 0;
		if (showTime.contains("<font style=background-color=red>")) {
			showTime = "";// 为中场时,已开赛时间设为空
		} else if (showTime.contains("Start")) {
			status = -1;
			showTime = "";// 未开赛时,已开赛时间设为空
		} else {
			status = Integer.parseInt(showTime.substring(0, 1));
			showTime = showTime.substring(showTime.indexOf("^") + 1, showTime.length());
		}

		// 主队进球数
		int homeG = HttpUtil.getJsonArrayIntValue(lineArray, HgConstant.ARRAY_LIVE_MATCH_HOST_NUM);
		homeG = homeG < 0 ? 0 : homeG;
		// 客队进球数
		int awayG = HttpUtil.getJsonArrayIntValue(lineArray, HgConstant.ARRAY_LIVE_MATCH_CUSTOMER_NUM);
		awayG = awayG < 0 ? 0 : awayG;

		// 主队红牌数
		int homeYC = HttpUtil.getJsonArrayIntValue(lineArray, HgConstant.ARRAY_LIVE_MATCH_HOST_RED);
		homeYC = homeYC < 0 ? 0 : homeYC;
		// 客队红牌数
		int awayYC = HttpUtil.getJsonArrayIntValue(lineArray, HgConstant.ARRAY_LIVE_MATCH_CUSTOMER_RED);
		awayYC = awayYC < 0 ? 0 : awayYC;

		// 设置赛事信息
		LiveMatch liveMatch = new LiveMatch();
		liveMatch.setStatus(status);
		liveMatch.setShowTime(showTime);
		liveMatch.setHomeGoal(homeG);
		liveMatch.setHomeYC(homeYC);
		liveMatch.setAwayGoal(awayG);
		liveMatch.setAwayYC(awayYC);
		return liveMatch;
	}
	
	
	private LiveMatch findBasketballLiveMatch(JSONArray lineArray){
		// 显示时间(已开赛时间)
		String showTime = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.BASKETBALL_ARRAY_LIVE_MATCH_PLAYED_TIME);
		
		String session = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.BASKETBALL_ARRAY_LIVE_MATCH_PLAYED_SESSION);
		
		String lastGoal = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.BASKETBALL_ARRAY_LIVE_MATCH_PLAYED_SESSION);
		// 小节信息 0为中场,1为上半场,2为下半场
		int status = 0;
		if(session.equals("HT")){
			status = 0;
		}else if(session.equals("Q1")){
			status = 1;
		}else if(session.equals("Q2")){
			status = 2;
		}else if(session.equals("Q3")){
			status = 3;
		}else if(session.equals("Q4")){
			status = 4;
		}else if(session.equals("ET")){
			status = 5;
		}
		// 主队进球数
		int homeG = HttpUtil.getJsonArrayIntValue(lineArray, HgConstant.BASKETBALL_LIVE_MATCH_HOST_NUM);
		homeG = homeG < 0 ? 0 : homeG;
		// 客队进球数
		int awayG = HttpUtil.getJsonArrayIntValue(lineArray, HgConstant.BASKETBALL_LIVE_MATCH_CUSTOMER_NUM);
		awayG = awayG < 0 ? 0 : awayG;


		// 设置赛事信息
		LiveMatch liveMatch = new LiveMatch();
		liveMatch.setStatus(status);
		liveMatch.setLastGoal(lastGoal);
		liveMatch.setShowTime(showTime);
		liveMatch.setHomeGoal(homeG);
		liveMatch.setAwayGoal(awayG);
		return liveMatch;
	}
	
	
	
	
	private LiveMatch findIennisLiveMatch(JSONArray lineArray){
		
		String nowServer = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.TENNIS_LIVE_MATCH_NOW_SERVER);
		
		int hgame = HttpUtil.getJsonArrayIntValue(lineArray, HgConstant.TENNIS_LIVE_MATCH_HOST_GAME);
		hgame = hgame < 0 ? 0 : hgame;
		int agame = HttpUtil.getJsonArrayIntValue(lineArray, HgConstant.TENNIS_LIVE_MATCH_AWAY_GAME);
		agame = agame < 0 ? 0 : agame;
		
		int hset = HttpUtil.getJsonArrayIntValue(lineArray, HgConstant.TENNIS_LIVE_MATCH_HOST_SET);
		hset = hset < 0 ? 0 : hset;
		int aset = HttpUtil.getJsonArrayIntValue(lineArray, HgConstant.TENNIS_LIVE_MATCH_AWAY_SET);
		aset = aset < 0 ? 0 : aset;
		
		String hpoint = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.TENNIS_LIVE_MATCH_HOST_POINT);
		if(HgConstant.TENNIS_LIVE_POINT_NAME_SOURCE.equals(hpoint)){
			hpoint = HgConstant.TENNIS_LIVE_POINT_NAME_TARGET;
		}
		String apoint = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.TENNIS_LIVE_MATCH_AWAY_POINT);
		if(HgConstant.TENNIS_LIVE_POINT_NAME_SOURCE.equals(hpoint)){
			apoint = HgConstant.TENNIS_LIVE_POINT_NAME_TARGET;
		}


		// 设置赛事信息
		LiveMatch liveMatch = new LiveMatch();
		
		liveMatch.setNowServer(nowServer);
		liveMatch.setHomeGoal(hgame);
		liveMatch.setAwayGoal(agame);
		liveMatch.setHboutCoal(hset);
		liveMatch.setAboutCoal(aset);
		liveMatch.setHscoreCoal(hpoint);
		liveMatch.setAscoreCoal(apoint);
		
		return liveMatch;
	}
	
	
	private LiveMatch findVolleyballLiveMatch(JSONArray lineArray){
		
		//排球就是什么都没有

		// 设置赛事信息
		LiveMatch liveMatch = new LiveMatch();
		
		
		return liveMatch;
	}

	private LiveMatch findOtherLiveMatch(JSONArray lineArray){
		
		
		int hgame = HttpUtil.getJsonArrayIntValue(lineArray, HgConstant.TENNIS_LIVE_MATCH_HOST_GAME);
		hgame = hgame < 0 ? 0 : hgame;
		int agame = HttpUtil.getJsonArrayIntValue(lineArray, HgConstant.TENNIS_LIVE_MATCH_AWAY_GAME);
		agame = agame < 0 ? 0 : agame;


		// 设置赛事信息
		LiveMatch liveMatch = new LiveMatch();
		
		liveMatch.setHomeGoal(hgame);
		liveMatch.setAwayGoal(agame);
		
		return liveMatch;
	}
	
	/**
	 * 冠军赛事
	 * @param nodeTaskInput
	 * @param sportinfo
	 * @param lineArray
	 * @param snatchTime
	 * @return
	 */
	private Matchinfo findMatchinfoFirst(NodeTaskInput nodeTaskInput,Sportinfo sportinfo,JSONArray lineArray,String snatchTime){
		// 赛事信息
		Matchinfo match = null;
		// 获取赛事主队名称
		String firstName = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_MATCH_FIRST_NAME);
		firstName = HttpUtil.dealName(firstName);// 去掉赛事主队名称中所有的空格
		String firstId = SnatchConstantUtil.foundSelid("", firstName, SnatchConstant.THIRD_SYSTEM_HG_VALUE);
		
		
		
		// 判断赛事是否存在
		if (null != sportinfo.getMatchs()) {
			for (Matchinfo mat : sportinfo.getMatchs()) {
				if (mat.getMatchselfID().equals(firstId)) {
					return mat;
				}
			}
		}
		match = new Matchinfo();
		// 获取赛事开赛时间
		String startTime = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_MATCH_FIRST_TIME);
		startTime = HgUtil.dealStartTime(startTime, nodeTaskInput.getItemType());
		// 设置赛事信息
		/*match.setSelfID(matchselfID);
		match.setName(matchName);// 赛事名称
*/		match.setMatchselfID(firstId);
		match.setMatchName(firstName);
		match.setMatchType(nodeTaskInput.getItemType());
		match.setStartTime(startTime);// 开赛时间"yyyy-MM-dd hh24:mm:ss"
		match.setSnatchTime(snatchTime);// 抓取时间戳"yyyy-MM-dd hh24:mm:ss"
		sportinfo.getMatchs().add(match);
		return match;
	}
	
	
	/**
	 * 合并联赛数据
	 * @param sports
	 * @return
	 */
	private List<Sportinfo> bineSportinfo(List<Sportinfo> sports){
		List<Sportinfo>  sportinfos = new ArrayList<Sportinfo>(); // 用于存取最后的联赛
		Map<String,Sportinfo> map = new HashMap<String, Sportinfo>(); //用于存放联赛,key=联赛名
		
		for(Sportinfo sportinfo : sports){
			Sportinfo temSportinfo = map.get(sportinfo.getName());
			if(null != temSportinfo){
				List<Matchinfo> matchs = bineMatchinfo(sportinfo.getMatchs(),temSportinfo.getMatchs());
				temSportinfo.setMatchs(matchs);
			}else{
				map.put(sportinfo.getName(), sportinfo);
			}
		}
		Iterator<Sportinfo> iter = map.values().iterator();
		while(iter.hasNext()){
			sportinfos.add(iter.next());
		}
		return sportinfos;
	}
	
	
	private List<Matchinfo> bineMatchinfo(List<Matchinfo> match1,List<Matchinfo> match2){
		List<Matchinfo> list = new ArrayList<Matchinfo>();
		Map<String,Matchinfo> matchmap = new HashMap<String, Matchinfo>();
		for(Matchinfo matchinfi : match1){
			matchmap.put(matchinfi.getMatchselfID(), matchinfi);
		}
		
		for(Matchinfo matchinfi : match2){
			Matchinfo temMatchinfo = matchmap.get(matchinfi.getMatchselfID());
			/**
			 * 如果存在则合并玩法
			 */
			if(null != temMatchinfo){
				temMatchinfo.getPlayinfos().addAll(matchinfi.getPlayinfos());
			}else{
				matchmap.put(matchinfi.getMatchselfID(), matchinfi);
			}
		}
		
		Iterator<Matchinfo> iter = matchmap.values().iterator();
		while(iter.hasNext()){
			list.add(iter.next());
		}
		return list;
	}
	
	
	private List<Object> findJsonData(String dataContext) throws Exception{
		List<Object> pageResult = new ArrayList<Object>();
		if(dataContext.contains(HgConstant.PARENT_T_PAGE)){
			dataContext = dataContext.substring(dataContext.indexOf(HgConstant.PARENT_T_PAGE), dataContext.indexOf(HgConstant.PARENT_GAMECOUNT));
			InputStream is = new ByteArrayInputStream(dataContext.toString().getBytes());
			BufferedReader reader = new BufferedReader(new InputStreamReader(is));
			for (String line = reader.readLine(); null != line; line = reader.readLine()) {
				line = line.trim();
				if (line.contains(HgConstant.PARENT_GAMEFT)) {
					pageResult.add(JSONArray.parseArray("[" + line.substring(line.indexOf("'"), line.lastIndexOf("'") + 1) + ",'" + "" + "']"));
				}
			}
		}
		return pageResult;
	}
	
	private List<Object> findJsonDataFirst(String dataContext) throws Exception{
		List<Object> pageResult = new ArrayList<Object>();
		if(dataContext.contains(HgConstant.PARENT_FIRST_GAMECOUNT)){
			dataContext = dataContext.substring(dataContext.indexOf(HgConstant.PARENT_FIRST_GAMECOUNT), dataContext.indexOf(HgConstant.PARENT_FIRST_GAMOUNT));
			InputStream is = new ByteArrayInputStream(dataContext.toString().getBytes());
			BufferedReader reader = new BufferedReader(new InputStreamReader(is));
			for (String line = reader.readLine(); null != line; line = reader.readLine()) {
				line = line.trim();
				if (line.contains(HgConstant.PARENT_FIRST_GAMEFT)) {
					pageResult.add(JSONArray.parseArray("[" + line.substring(line.indexOf("'"), line.lastIndexOf("'") + 1) + ",'" + "" + "']"));
				}
			}
		}
		return pageResult;
	}
	

	@Override
	public void clearData(String snatchItem) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public int logout(ThirdInfo thirdInfoVO) throws Exception {
		// TODO Auto-generated method stub
		return 0;
	}

	
	/**
	 * 获得收盘状态(区分上半场和全场的收盘)
	 * 
	 * @param match
	 * @param status
	 *            0中场,1上半场,2下半场
	 * @return result 0未收盘,1全部盘口收盘,2上半场盘口收盘
	 */
	private int getMatchCloseStatus(Matchinfo match, int status) {
		int result = 1;

		if (null == match) {
			return result;
		}

		for (Playinfo playinfo : match.getPlayinfos()) {
			if (status == 1) { // 上半场
				result = 2;// 上半场盘口收盘
				if (playinfo.getGametime() == 2) {
					for (TradingItem tradingItem : playinfo.getTradingItems()) {
						if (tradingItem.getRatio() != 0) {
							result = 0;
							return result;
						}
					}
				}
			} else {// 中场或下半场
				for (TradingItem tradingItem : playinfo.getTradingItems()) {
					if (tradingItem.getRatio() != 0) {
						result = 0;
						return result;
					}
				}
			}
		}
		return result;
	}

	/**
	 * 比较两个map,返回变化的map
	 * 
	 * @param oldLiveMatchList
	 * @param newLiveMatchList
	 * @return
	 *//*
	public ArrayList<LiveMatch> compareMap(ArrayList<LiveMatch> oldLiveMatchList, ArrayList<LiveMatch> newLiveMatchList) {
		if (null == oldLiveMatchList || oldLiveMatchList.size() <= 0) {
			return newLiveMatchList;
		}
		if (null == newLiveMatchList || newLiveMatchList.size() <= 0) {
			return null;
		}

		ArrayList<LiveMatch> updatedLiveMatchs = new ArrayList<LiveMatch>();

		for (LiveMatch liveMatch : newLiveMatchList) {
			LiveMatch oldLiveMatch = null;
			LiveMatch newLiveMatch = null;

			int result = 0;

			newLiveMatch = liveMatch;

			for (LiveMatch liveMat : oldLiveMatchList) {
				if (liveMat.getMatchName().equals(liveMatch.getMatchName())) {
					oldLiveMatch = liveMat;
					result = oldLiveMatch.compareTo(newLiveMatch);
					if (result < 0) {
						updatedLiveMatchs.add(newLiveMatch);
					}
					oldLiveMatchList.remove(liveMat);
					break;
				} else {// 新增的赛事不发
					// updatedLiveMatchs.add(newLiveMatch);
				}
			}
		}
		return updatedLiveMatchs;
	}*/

	/**
	 * 获得盘中信息
	 * 
	 * @param jsonArrays
	 *            盘中信息的jsonArray列表
	 *//*
	private ArrayList<LiveMatch> parseGqLiveMatch(List<Object> jsonArrays) {
		if (null == jsonArrays || jsonArrays.size() <= 0) {
			return null;
		}

		// 盘中赛事
		ArrayList<LiveMatch> liveMatchList = new ArrayList<LiveMatch>();

		JSONArray lineArray = null;
		for (Object obj : jsonArrays) {
			lineArray = (JSONArray) obj;
			// 获取联赛名称
			String leagueName = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_LEAGUE_NAME);
			leagueName = HttpUtil.dealName(leagueName);// 去掉联赛中所有的空格

			LiveMatch liveMatch = new LiveMatch();// 盘中信息

			// 获取赛事主队名称
			String hostName = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_MATCH_HOST_NAME);
			hostName = HttpUtil.dealName(hostName);// 去掉赛事主队名称中所有的空格
			// 获取赛事客队名称
			String awayName = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_MATCH_CUSTOMER_NAME);
			awayName = HttpUtil.dealName(awayName);// 去掉赛事客队名称中所有的空格
			// 组合,即得:赛事名称
			String matchName = hostName + SnatchConstant.VS + awayName;

			if (null != liveMatchList && liveMatchList.size() > 0) {
				boolean filterSign = false;
				for (LiveMatch liveMat : liveMatchList) {
					if (liveMat.getMatchName().equals(matchName)) {
						filterSign = true;
						break;
					}
				}
				if (filterSign) {
					continue;
				}
			}

			// 显示时间(已开赛时间)
			String showTime = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_LIVE_MATCH_PLAYED_TIME);
			// 小节信息 0为中场,1为上半场,2为下半场
			int status = 0;
			if (showTime.contains("<font style=background-color=red>")) {
				showTime = "";// 为中场时,已开赛时间设为空
			} else if (showTime.contains("Start")) {
				status = -1;
				showTime = "";// 未开赛时,已开赛时间设为空
			} else {
				status = Integer.parseInt(showTime.substring(0, 1));
				showTime = showTime.substring(showTime.indexOf("^") + 1, showTime.length());
			}

			// 主队进球数
			int homeG = HttpUtil.getJsonArrayIntValue(lineArray, HgConstant.ARRAY_LIVE_MATCH_HOST_NUM);
			homeG = homeG < 0 ? 0 : homeG;
			// 客队进球数
			int awayG = HttpUtil.getJsonArrayIntValue(lineArray, HgConstant.ARRAY_LIVE_MATCH_CUSTOMER_NUM);
			awayG = awayG < 0 ? 0 : awayG;

			// 主队红牌数
			int homeYC = HttpUtil.getJsonArrayIntValue(lineArray, HgConstant.ARRAY_LIVE_MATCH_HOST_RED);
			homeYC = homeYC < 0 ? 0 : homeYC;
			// 客队红牌数
			int awayYC = HttpUtil.getJsonArrayIntValue(lineArray, HgConstant.ARRAY_LIVE_MATCH_CUSTOMER_RED);
			awayYC = awayYC < 0 ? 0 : awayYC;

			Integer snatchTimeArray[] = { lineArray.size() - 1 };
			String snatchTime = HttpUtil.getJsonArrayStringValue(lineArray, snatchTimeArray);

			// 设置赛事信息
			liveMatch.setLeagueName(leagueName);
			liveMatch.setMatchName(matchName);
			liveMatch.setShowTime(showTime);
			liveMatch.setSystemTime(snatchTime);// 系统时间

			liveMatch.setStatus(status);
			liveMatch.setHomeGoal(homeG);
			liveMatch.setHomeYC(homeYC);
			liveMatch.setAwayGoal(awayG);
			liveMatch.setAwayYC(awayYC);

			liveMatchList.add(liveMatch);
		}
		return liveMatchList;
	}
*/
	/**
	 * 解析皇冠死盘赔率数据
	 * 
	 * @param playinfos
	 *            玩法列表
	 * @param lineArray
	 *            需要解析的单式源数据
	 * @param marketID
	 *            投注盘类型 0香港盘 1印尼盘 2马来盘 3欧洲盘
	 * @param showior
	 *            显示位数
	 * @param iorpoints
	 *            赔率小数点位数
	 * @return
	 */
	private List<Playinfo> parseStandardOddsData(List<Playinfo> playinfos, JSONArray lineArray,String gameCode,String itemType, int marketID, String showior, String iorpoints) throws Exception {
		
		
		Integer[] ONETWO = null;
		Integer[] ALLOW = null;
		Integer[] STANDARD = null;
		Integer[] BIGSMALL = null;
		Integer[] BIGSMALL_HOST = null;
		Integer[] BIGSMALL_AWAY = null;
		
		
		Integer[] HF_ALLOW = null;
		Integer[] HF_BIGSMALL = null;
		Integer[] HF_STANDARD = null;
		
		int ALL_STANDARD = 0;
		
		String hostName = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_MATCH_HOST_NAME);
		int gametiem = findGameTime(hostName, gameCode);
		
		
		if(SnatchConstant.FOOTBALL.equals(gameCode)){
			ALL_STANDARD = HgConstant.PLAY_TYPE_ALL_STANDARD;
			if(SnatchConstant.SNATCH_TYPE_GQ.equals(itemType)){
				ALLOW = HgConstant.ARRAY_PLAY_ALLOW_WAY;
				ONETWO = HgConstant.GQ_ARRAY_PLAY_ONETWO_HOST_RATIO;
				BIGSMALL = HgConstant.ARRAY_PLAY_BIGSMALL_HOST_TRADINGITEM_NAME;
				STANDARD = HgConstant.GQ_PLAY_STANDARD_HOST_RATIO;
				HF_ALLOW = HgConstant.GQ_PLAY_ALLOW_WAY_HALF;
				HF_BIGSMALL = HgConstant.GQ_PLAY_BIGSMALL_HOST_TRADINGITEM_NAME_HALF;
				HF_STANDARD = HgConstant.GQ_PLAY_STANDARD_HOST_RATIO_HALF;
			}else{
				ALLOW = HgConstant.ARRAY_PLAY_ALLOW_WAY;
				ONETWO = HgConstant.ARRAY_PLAY_ONETWO_HOST_RATIO;
				STANDARD = HgConstant.SP_PLAY_STANDARD_HOST_RATIO;
				BIGSMALL = HgConstant.ARRAY_PLAY_BIGSMALL_HOST_TRADINGITEM_NAME;
				HF_ALLOW = HgConstant.SP_PLAY_ALLOW_WAY_HALF;
				HF_BIGSMALL = HgConstant.SP_PLAY_BIGSMALL_HOST_TRADINGITEM_NAME_HALF;
				HF_STANDARD = HgConstant.SP_PLAY_STANDARD_HOST_RATIO_HALF;
			}
		}else if(SnatchConstant.BASKETBALL.equals(gameCode)){
			ALL_STANDARD = HgConstant.PLAY_TYPE_BASKET_ALL_STANDARD;
			if(SnatchConstant.SNATCH_TYPE_GQ.equals(itemType)){
				ALLOW = HgConstant.ARRAY_PLAY_ALLOW_WAY;
				ONETWO = HgConstant.BASKET_GQ_PLAY_ONETWO_HOST_RATIO;
				BIGSMALL = HgConstant.ARRAY_PLAY_BIGSMALL_HOST_TRADINGITEM_NAME;
				STANDARD = HgConstant.BASKET_GQ_PLAY_STANDARD_HOST_RATIO;
				BIGSMALL_HOST = HgConstant.BASKET_GQ_PLAY_BIGSMALL_HOST_TRADINGITEM_BIG_NAME;
				BIGSMALL_AWAY = HgConstant.BASKET_GQ_PLAY_BIGSMALL_AWAY_TRADINGITEM_BIG_NAME;
			}else{
				ALLOW = HgConstant.ARRAY_PLAY_ALLOW_WAY;
				ONETWO = HgConstant.ARRAY_PLAY_ONETWO_HOST_RATIO;
				STANDARD = HgConstant.SP_PLAY_STANDARD_HOST_RATIO;
				BIGSMALL = HgConstant.ARRAY_PLAY_BIGSMALL_HOST_TRADINGITEM_NAME;
				BIGSMALL_HOST = HgConstant.BASKET_SP_PLAY_BIGSMALL_HOST_TRADINGITEM_BIG_NAME;
				BIGSMALL_AWAY = HgConstant.BASKET_SP_PLAY_BIGSMALL_AWAY_TRADINGITEM_BIG_NAME;
			}
		}else if(SnatchConstant.TENNIS.equals(gameCode)){
			ALL_STANDARD = HgConstant.PLAY_TYPE_BASKET_ALL_STANDARD;
			if(SnatchConstant.SNATCH_TYPE_GQ.equals(itemType)){
				ALLOW = HgConstant.ARRAY_PLAY_ALLOW_WAY;
				BIGSMALL = HgConstant.ARRAY_PLAY_BIGSMALL_HOST_TRADINGITEM_NAME;
				ONETWO = HgConstant.TENNIS_GQ_PLAY_ONETWO_HOST_TRADINGITEM_NAME;
				STANDARD = HgConstant.TENNIS_GQ_PLAY_STANDARD_HOST_RATIO;
				BIGSMALL_HOST = HgConstant.TENNIS_GQ_PLAY_BIGSMALL_HOST_TRADINGITEM_BIG_NAME;
				BIGSMALL_AWAY = HgConstant.TENNIS_GQ_PLAY_BIGSMALL_AWAY_TRADINGITEM_BIG_NAME;
			}else{
				//还没完成
				ALLOW = HgConstant.ARRAY_PLAY_ALLOW_WAY;    
				STANDARD = HgConstant.SP_PLAY_STANDARD_HOST_RATIO;
				ONETWO = HgConstant.ARRAY_PLAY_ONETWO_HOST_RATIO;
				BIGSMALL = HgConstant.ARRAY_PLAY_BIGSMALL_HOST_TRADINGITEM_NAME;
				BIGSMALL_HOST = HgConstant.BASKET_SP_PLAY_BIGSMALL_HOST_TRADINGITEM_BIG_NAME;
				BIGSMALL_AWAY = HgConstant.BASKET_SP_PLAY_BIGSMALL_AWAY_TRADINGITEM_BIG_NAME;
			}
		}else if(SnatchConstant.VOLLEYBALL.equals(gameCode)){
			ALL_STANDARD = HgConstant.PLAY_TYPE_BASKET_ALL_STANDARD;
			if(SnatchConstant.SNATCH_TYPE_GQ.equals(itemType)){
				ALLOW = HgConstant.ARRAY_PLAY_ALLOW_WAY;    
				BIGSMALL = HgConstant.ARRAY_PLAY_BIGSMALL_HOST_TRADINGITEM_NAME;
				/*ALLOW = HgConstant.ARRAY_PLAY_ALLOW_WAY;
				BIGSMALL = HgConstant.ARRAY_PLAY_BIGSMALL_HOST_TRADINGITEM_NAME;
				ONETWO = HgConstant.TENNIS_GQ_PLAY_ONETWO_HOST_TRADINGITEM_NAME;
				STANDARD = HgConstant.TENNIS_GQ_PLAY_STANDARD_HOST_RATIO;
				BIGSMALL_HOST = HgConstant.TENNIS_GQ_PLAY_BIGSMALL_HOST_TRADINGITEM_BIG_NAME;
				BIGSMALL_AWAY = HgConstant.TENNIS_GQ_PLAY_BIGSMALL_AWAY_TRADINGITEM_BIG_NAME;*/
			}else{
				//还没完成
				ALLOW = HgConstant.ARRAY_PLAY_ALLOW_WAY;    
				STANDARD = HgConstant.SP_PLAY_STANDARD_HOST_RATIO;
				BIGSMALL = HgConstant.ARRAY_PLAY_BIGSMALL_HOST_TRADINGITEM_NAME;
				ONETWO = HgConstant.ARRAY_PLAY_ONETWO_HOST_RATIO;
			}
		}else if(SnatchConstant.BASEBALL.equals(gameCode)){
			ALL_STANDARD = HgConstant.PLAY_TYPE_BASKET_ALL_STANDARD;
			if(SnatchConstant.SNATCH_TYPE_GQ.equals(itemType)){
				/*ALLOW = HgConstant.ARRAY_PLAY_ALLOW_WAY;
				BIGSMALL = HgConstant.ARRAY_PLAY_BIGSMALL_HOST_TRADINGITEM_NAME;
				ONETWO = HgConstant.TENNIS_GQ_PLAY_ONETWO_HOST_TRADINGITEM_NAME;
				STANDARD = HgConstant.TENNIS_GQ_PLAY_STANDARD_HOST_RATIO;
				BIGSMALL_HOST = HgConstant.TENNIS_GQ_PLAY_BIGSMALL_HOST_TRADINGITEM_BIG_NAME;
				BIGSMALL_AWAY = HgConstant.TENNIS_GQ_PLAY_BIGSMALL_AWAY_TRADINGITEM_BIG_NAME;*/
			}else{
				//还没完成
				ALLOW = HgConstant.ARRAY_PLAY_ALLOW_WAY;    
				STANDARD = HgConstant.SP_PLAY_STANDARD_HOST_RATIO;
				BIGSMALL = HgConstant.ARRAY_PLAY_BIGSMALL_HOST_TRADINGITEM_NAME;
			}
		}else if(SnatchConstant.OTHER.equals(gameCode)){
			ALL_STANDARD = HgConstant.PLAY_TYPE_BASKET_ALL_STANDARD;
			if(SnatchConstant.SNATCH_TYPE_GQ.equals(itemType)){
				ALLOW = HgConstant.ARRAY_PLAY_ALLOW_WAY;
				BIGSMALL = HgConstant.ARRAY_PLAY_BIGSMALL_HOST_TRADINGITEM_NAME;
			}else{
				ALLOW = HgConstant.ARRAY_PLAY_ALLOW_WAY;
				BIGSMALL = HgConstant.ARRAY_PLAY_BIGSMALL_HOST_TRADINGITEM_NAME;
				STANDARD = HgConstant.SP_PLAY_STANDARD_HOST_RATIO;
				ONETWO = HgConstant.ARRAY_PLAY_ONETWO_HOST_RATIO;
			}
		}
		
		
		//全场单双
		
		Playinfo onetwof = parseOnetwollPlayinfo(lineArray, ONETWO,gametiem,HgConstant.PLAY_TYPE_ALL_ONETWO, marketID, showior, iorpoints);
		if(null != onetwof){
			playinfos .add(onetwof);
		}
		
		//全场让球
		Playinfo allowf = parseAllowPlayinfo(lineArray, ALLOW,gametiem, HgConstant.PLAY_TYPE_ALL_ALLOW, marketID, showior, iorpoints);
		if(null != allowf){
			playinfos .add(allowf);
		}
		
		//全场大小球
		Playinfo bigsmallf = parseBigsmallPlayinfo(lineArray, BIGSMALL,gametiem,  HgConstant.PLAY_TYPE_ALL_BIGSMALL,false, marketID, showior, iorpoints);
		if(null != bigsmallf){
			playinfos .add(bigsmallf);
		}
		
		//全场标准盘
		Playinfo standardf = parseStandardPlayinfo(lineArray, STANDARD,gametiem, ALL_STANDARD,SnatchConstant.FOOTBALL.equals(gameCode)?true:false, marketID, showior, iorpoints);
		if(null != standardf){
			playinfos .add(standardf);
		}
		
		if(SnatchConstant.FOOTBALL.equals(gameCode)){
			//上半场让球
			Playinfo allowh = parseAllowPlayinfo(lineArray,HF_ALLOW,gametiem, HgConstant.PLAY_TYPE_HALF_ALLOW, marketID, showior, iorpoints);
			if(null != allowh){
				playinfos .add(allowh);
			}
			//上半场大小球
			Playinfo bigsmallh = parseBigsmallPlayinfo(lineArray,HF_BIGSMALL,gametiem, HgConstant.PLAY_TYPE_HALF_BIGSMALL,false, marketID, showior, iorpoints);
			if(null != bigsmallh){
				playinfos .add(bigsmallh);
			}
			
			//上半场标准盘
			Playinfo standardh = parseStandardPlayinfo(lineArray, HF_STANDARD,gametiem,  HgConstant.PLAY_TYPE_HALF_STANDARD,true, marketID, showior, iorpoints);
			if(null != standardh){
				playinfos .add(standardh);
			}
		}else {
			//全场大小球
			Playinfo bigsmallhostf = parseBigsmallTeamPlayinfo(lineArray, BIGSMALL_HOST,gametiem, HgConstant.PLAY_TYPE_BASKET_ALL_BIGSMALL_HOST, marketID, showior, iorpoints);
			if(null != bigsmallhostf){
				playinfos .add(bigsmallhostf);
			}
			//全场大小球
			Playinfo bigsmallawayf = parseBigsmallTeamPlayinfo(lineArray, BIGSMALL_AWAY,gametiem,HgConstant.PLAY_TYPE_BASKET_ALL_BIGSMALL_AWAY, marketID, showior, iorpoints);
			if(null != bigsmallawayf){
				playinfos .add(bigsmallawayf);
			}
		}
		
		return playinfos;
	}
	
	
	/**
	 * 解析皇冠篮球滚球赔率数据
	 * 
	 * @param playinfos
	 *            玩法列表
	 * @param lineArray
	 *            需要解析的滚球源数据
	 * @param marketID
	 *            投注盘类型 0香港盘 1印尼盘 2马来盘 3欧洲盘
	 * @param showior
	 *            显示位数
	 * @param iorpoints
	 *            赔率小数点位数
	 * @return
	 *//*
	private List<Playinfo> parseGqOddsBasketData(List<Playinfo> playinfos, JSONArray lineArray, int marketID, String showior, String iorpoints) throws Exception {
		// 玩法信息
		Playinfo playinfo = null;

		String allowWay = "";// 全场或上半场的让球方
		String allowNum = "";// 全场或上半场的让球数
		double hostRation = 0;// 主队赔率
		double customerRation = 0;// 客队赔率
		double thirdRatio = 0;// 和赔率
		String hostTradingItem = "";// 主队交易项
		String customerTradingItem = "";// 客队交易项
		String hostRationStr = "";// 主队赔率
		String customerRationStr = "";// 客队赔率
		String thirdRatioStr = "";// 和赔率

		// 主队交易项id
		String hostTradingItemId = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_TRADING_ITEM_ID_HOST);
		// 客队交易项id
		String customerTradingItemId = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_TRADING_ITEM_ID_CUSTOMER);

		// 获取全场id
		String playTypeAllId = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_PLAY_TYPE_ALL_ID);
		// 获取上半场id
		String palyTypeHalfId = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.GQ_PLAY_TYPE_HALF_ID);
		*//** --------------------------全场-------------------------- **//*
		*//**************************** 让球盘 ****************************//*
		// 让球方
		allowWay = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_PLAY_ALLOW_WAY);

		// 让球个数
		allowNum = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_PLAY_ALLOW_NUM);

		// 让球盘主队赔率
		hostRation = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_ALLOW_HOST_RATIO);

		// 让球盘客队赔率
		customerRation = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_ALLOW_CUSTOMER_RATIO);

		String allowRatio[] = HgUtil.get_other_ioratio(marketID, hostRation, customerRation, showior, iorpoints);

		if (!HttpUtil.isNull(allowNum)) {
			playinfo = getPlayinfo(HgConstant.PLAY_TYPE_ALL_ALLOW, playTypeAllId, Double.parseDouble(allowRatio[0]), Double.parseDouble(allowRatio[1]), 0, allowNum, allowWay, hostTradingItemId, customerTradingItemId);
			playinfos.add(playinfo);
		}
		*//**************************** 单双 ***************************//*
		// 单双盘主队交易项
		hostTradingItem = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.GQ_ARRAY_PLAY_ONETWO_HOST_TRADINGITEM_NAME);
		// 单双盘主队赔率
		hostRation = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.GQ_ARRAY_PLAY_ONETWO_HOST_RATIO);

		// 单双盘客队交易项
		customerTradingItem = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.GQ_ARRAY_PLAY_ONETWO_CUSTOMER_TRADINGITEM_NAME);
		// 单双盘客队赔率
		customerRation = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.GQ_ARRAY_PLAY_ONETWO_CUSTOMER_RATIO);
		if (!HttpUtil.isNull(hostTradingItem) && !HttpUtil.isNull(customerTradingItem)) {
			hostRation = HgUtil.tranOddsByOddsType(marketID, hostRation, Integer.parseInt(iorpoints));
			customerRation = HgUtil.tranOddsByOddsType(marketID, customerRation, Integer.parseInt(iorpoints));
			
			playinfo = getPlayinfo(HgConstant.PLAY_TYPE_ALL_ONETWO, playTypeAllId, hostRation, customerRation, 0, hostTradingItem, customerTradingItem, hostTradingItemId, customerTradingItemId);
			playinfos.add(playinfo);
		}
		*//**************************** 大小球 ****************************//*
		// 大小盘主队交易项
		hostTradingItem = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_PLAY_BIGSMALL_HOST_TRADINGITEM_NAME);

		// 大小盘主队赔率
		hostRation = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_BIGSMALL_HOST_RATIO);

		// 大小盘客队交易项
		customerTradingItem = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_PLAY_BIGSMALL_CUSTOMER_TRADINGITEM_NAME);

		// 大小盘客队赔率
		customerRation = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_BIGSMALL_CUSTOMER_RATIO);

		String bigsmallRatio[] = HgUtil.get_other_ioratio(marketID, customerRation, hostRation, showior, iorpoints);

		if (!HttpUtil.isNull(hostTradingItem) && !HttpUtil.isNull(customerTradingItem)) {
			playinfo = getPlayinfo(HgConstant.PLAY_TYPE_ALL_BIGSMALL, playTypeAllId, Double.parseDouble(bigsmallRatio[1]), Double.parseDouble(bigsmallRatio[0]), 0, hostTradingItem, customerTradingItem, hostTradingItemId, customerTradingItemId);
			playinfos.add(playinfo);
		}
		*//**************************** 标准盘 ****************************//*
		// 标准盘主队赔率
		hostRation = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.GQ_PLAY_STANDARD_HOST_RATIO);
		hostRationStr = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.GQ_PLAY_STANDARD_HOST_RATIO);

		// 标准盘客队赔率
		customerRation = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.GQ_PLAY_STANDARD_CUSTOMER_RATIO);
		customerRationStr = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.GQ_PLAY_STANDARD_CUSTOMER_RATIO);


		if (!HttpUtil.isNull(hostRationStr) && !HttpUtil.isNull(customerRationStr)) {
			playinfo = getPlayinfo(HgConstant.PLAY_TYPE_BASKET_ALL_STANDARD, playTypeAllId, hostRation, customerRation, thirdRatio, "", "", hostTradingItemId, customerTradingItemId);
			playinfos.add(playinfo);
		}
		*//** --------------------------上半场-------------------------- **//*
		
		*//** --------------------------上半场-------------------------- **//*
		*//**************************** 主队大小球 ****************************//*
		// 主队大小球 大交易项
		hostTradingItem = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.BASKET_GQ_PLAY_BIGSMALL_HOST_TRADINGITEM_BIG_NAME);

		//  主队大小球 大赔率
		hostRation = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.BASKET_GQ_PLAY_BIGSMALL_HOST_TRADINGITEM_BIG_RATIO);

		// 主队大小球 小交易项
		customerTradingItem = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.BASKET_GQ_PLAY_BIGSMALL_HOST_TRADINGITEM_SMALL_NAME);
		// 主队大小球 小赔率
		customerRation = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.BASKET_GQ_PLAY_BIGSMALL_HOST_TRADINGITEM_SMALL_RATIO);
		String bigsmallRatioHost[] = HgUtil.get_other_ioratio(marketID, customerRation, hostRation, showior, iorpoints);

		if (!HttpUtil.isNull(hostTradingItem) && !HttpUtil.isNull(customerTradingItem)) {
			playinfo = getPlayinfo(HgConstant.PLAY_TYPE_BASKET_ALL_BIGSMALL_HOST, playTypeAllId, Double.parseDouble(bigsmallRatioHost[1]), Double.parseDouble(bigsmallRatioHost[0]), 0, hostTradingItem, customerTradingItem, hostTradingItemId, customerTradingItemId);
			playinfos.add(playinfo);
		}
		
		
		*//**************************** 客队队大小球 ****************************//*
		// 主队大小球 大交易项
		hostTradingItem = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.BASKET_GQ_PLAY_BIGSMALL_AWAY_TRADINGITEM_BIG_NAME);

		//  主队大小球 大赔率
		hostRation = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.BASKET_GQ_PLAY_BIGSMALL_AWAY_TRADINGITEM_BIG_RATIO);

		// 主队大小球 小交易项
		customerTradingItem = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.BASKET_GQ_PLAY_BIGSMALL_AWAY_TRADINGITEM_SMALL_NAME);
		// 主队大小球 小赔率
		customerRation = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.BASKET_GQ_PLAY_BIGSMALL_AWAY_TRADINGITEM_SMALL_RATIO);
		String bigsmallRatioAway[] = HgUtil.get_other_ioratio(marketID, customerRation, hostRation, showior, iorpoints);

		if (!HttpUtil.isNull(hostTradingItem) && !HttpUtil.isNull(customerTradingItem)) {
			playinfo = getPlayinfo(HgConstant.PLAY_TYPE_BASKET_ALL_BIGSMALL_AWAY, playTypeAllId, Double.parseDouble(bigsmallRatioAway[1]), Double.parseDouble(bigsmallRatioAway[0]), 0, hostTradingItem, customerTradingItem, hostTradingItemId, customerTradingItemId);
			playinfos.add(playinfo);
		}

		
		
		

		return playinfos;
	}
	
	
	*/
	
	
	/*
		
	*//**
	 * 解析皇冠死盘赔率数据
	 * 
	 * @param playinfos
	 *            玩法列表
	 * @param lineArray
	 *            需要解析的单式源数据
	 * @param marketID
	 *            投注盘类型 0香港盘 1印尼盘 2马来盘 3欧洲盘
	 * @param showior
	 *            显示位数
	 * @param iorpoints
	 *            赔率小数点位数
	 * @return
	 *//*
	private List<Playinfo> parseSpOddsBasketData(List<Playinfo> playinfos, JSONArray lineArray, int marketID, String showior, String iorpoints) throws Exception {
		// 玩法信息
		Playinfo playinfo = null;

		String allowWay = "";// 全场或上半场的让球方
		String allowNum = "";// 全场或上半场的让球数
		double hostRation = 0;// 主队赔率
		double customerRation = 0;// 客队赔率
		String hostTradingItem = "";// 主队交易项
		String customerTradingItem = "";// 客队交易项
		String hostRationStr = "";// 主队赔率
		String customerRationStr = "";// 客队赔率
		String thirdRatioStr = "";// 和赔率
		
		// 主队交易项id
		String hostTradingItemId = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_TRADING_ITEM_ID_HOST);
		// 客队交易项id
		String customerTradingItemId = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_TRADING_ITEM_ID_CUSTOMER);

		// 获取全场id
		String playTypeAllId = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_PLAY_TYPE_ALL_ID);
		*//** --------------------------全场-------------------------- **//*
		*//**************************** 单双 ***************************//*
		// 单双盘主队交易项
		hostTradingItem = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_PLAY_ONETWO_HOST_TRADINGITEM_NAME);
		// 单双盘主队赔率
		hostRation = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_ONETWO_HOST_RATIO);

		// 单双盘客队交易项
		customerTradingItem = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_PLAY_ONETWO_CUSTOMER_TRADINGITEM_NAME);
		// 单双盘客队赔率
		customerRation = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_ONETWO_CUSTOMER_RATIO);
		if (!HttpUtil.isNull(hostTradingItem) && !HttpUtil.isNull(customerTradingItem)) {
			hostRation = HgUtil.tranOddsByOddsType(marketID, hostRation, Integer.parseInt(iorpoints));
			customerRation = HgUtil.tranOddsByOddsType(marketID, customerRation, Integer.parseInt(iorpoints));
			
			playinfo = getPlayinfo(HgConstant.PLAY_TYPE_ALL_ONETWO, playTypeAllId, hostRation, customerRation, 0, hostTradingItem, customerTradingItem, hostTradingItemId, customerTradingItemId);
			playinfos.add(playinfo);
		}
		*//**************************** 让球盘 ****************************//*
		// 让球方
		allowWay = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_PLAY_ALLOW_WAY);

		// 让球个数
		allowNum = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_PLAY_ALLOW_NUM);

		// 让球盘主队赔率
		hostRation = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_ALLOW_HOST_RATIO);

		// 让球盘客队赔率
		customerRation = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_ALLOW_CUSTOMER_RATIO);

		String allowRatio[] = HgUtil.get_other_ioratio(marketID, hostRation, customerRation, showior, iorpoints);
		if (!HttpUtil.isNull(allowNum)) {
			playinfo = getPlayinfo(HgConstant.PLAY_TYPE_ALL_ALLOW, playTypeAllId, Double.parseDouble(allowRatio[0]), Double.parseDouble(allowRatio[1]), 0, allowNum, allowWay, hostTradingItemId, customerTradingItemId);
			playinfos.add(playinfo);
		}
		*//**************************** 大小球 ****************************//*
		// 大小盘主队交易项
		hostTradingItem = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_PLAY_BIGSMALL_HOST_TRADINGITEM_NAME);

		// 大小盘主队赔率
		hostRation = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_BIGSMALL_HOST_RATIO);

		// 大小盘客队交易项
		customerTradingItem = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_PLAY_BIGSMALL_CUSTOMER_TRADINGITEM_NAME);

		// 大小盘客队赔率
		customerRation = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_BIGSMALL_CUSTOMER_RATIO);

		String bigsmallRatio[] = HgUtil.get_other_ioratio(marketID, customerRation, hostRation, showior, iorpoints);
		if (!HttpUtil.isNull(hostTradingItem) && !HttpUtil.isNull(customerTradingItem)) {
			playinfo = getPlayinfo(HgConstant.PLAY_TYPE_ALL_BIGSMALL, playTypeAllId, Double.parseDouble(bigsmallRatio[1]), Double.parseDouble(bigsmallRatio[0]), 0, hostTradingItem, customerTradingItem, hostTradingItemId, customerTradingItemId);
			playinfos.add(playinfo);
		}
		*//**************************** 标准盘 ****************************//*
		// 标准盘主队赔率
		hostRation = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.SP_PLAY_STANDARD_HOST_RATIO);
		hostRationStr = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.SP_PLAY_STANDARD_HOST_RATIO);

		// 标准盘客队赔率
		customerRation = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.SP_PLAY_STANDARD_CUSTOMER_RATIO);
		customerRationStr = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.SP_PLAY_STANDARD_CUSTOMER_RATIO);


		if (!HttpUtil.isNull(hostRationStr) && !HttpUtil.isNull(customerRationStr) ) {
			playinfo = getPlayinfo(HgConstant.PLAY_TYPE_BASKET_ALL_STANDARD, playTypeAllId, hostRation, customerRation, 0, "", "", hostTradingItemId, customerTradingItemId);
			playinfos.add(playinfo);
		}
		*//** --------------------------上半场-------------------------- **//*
		*//**************************** 主队大小球 ****************************//*
		// 主队大小球 大交易项
		hostTradingItem = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.BASKET_SP_PLAY_BIGSMALL_HOST_TRADINGITEM_BIG_NAME);

		//  主队大小球 大赔率
		hostRation = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.BASKET_SP_PLAY_BIGSMALL_HOST_TRADINGITEM_BIG_RATIO);

		// 主队大小球 小交易项
		customerTradingItem = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.BASKET_SP_PLAY_BIGSMALL_HOST_TRADINGITEM_SMALL_NAME);
		// 主队大小球 小赔率
		customerRation = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.BASKET_SP_PLAY_BIGSMALL_HOST_TRADINGITEM_SMALL_RATIO);
		String bigsmallRatioHost[] = HgUtil.get_other_ioratio(marketID, customerRation, hostRation, showior, iorpoints);

		if (!HttpUtil.isNull(hostTradingItem) && !HttpUtil.isNull(customerTradingItem)) {
			playinfo = getPlayinfo(HgConstant.PLAY_TYPE_BASKET_ALL_BIGSMALL_HOST, playTypeAllId, Double.parseDouble(bigsmallRatioHost[1]), Double.parseDouble(bigsmallRatioHost[0]), 0, hostTradingItem, customerTradingItem, hostTradingItemId, customerTradingItemId);
			playinfos.add(playinfo);
		}
		
		
		*//**************************** 客队队大小球 ****************************//*
		// 主队大小球 大交易项
		hostTradingItem = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.BASKET_SP_PLAY_BIGSMALL_AWAY_TRADINGITEM_BIG_NAME);

		//  主队大小球 大赔率
		hostRation = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.BASKET_SP_PLAY_BIGSMALL_AWAY_TRADINGITEM_BIG_RATIO);

		// 主队大小球 小交易项
		customerTradingItem = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.BASKET_SP_PLAY_BIGSMALL_AWAY_TRADINGITEM_SMALL_NAME);
		// 主队大小球 小赔率
		customerRation = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.BASKET_SP_PLAY_BIGSMALL_AWAY_TRADINGITEM_SMALL_RATIO);
		String bigsmallRatioAway[] = HgUtil.get_other_ioratio(marketID, customerRation, hostRation, showior, iorpoints);

		if (!HttpUtil.isNull(hostTradingItem) && !HttpUtil.isNull(customerTradingItem)) {
			playinfo = getPlayinfo(HgConstant.PLAY_TYPE_BASKET_ALL_BIGSMALL_AWAY, playTypeAllId, Double.parseDouble(bigsmallRatioAway[1]), Double.parseDouble(bigsmallRatioAway[0]), 0, hostTradingItem, customerTradingItem, hostTradingItemId, customerTradingItemId);
			playinfos.add(playinfo);
		}

		return playinfos;
	}
	
	
	
	*/
	
	
	
	
	
	
	
	/**
	 * 解析过关数据
	 * 
	 * @param playinfos
	 *            玩法列表
	 * @param lineArray
	 *            需要解析的滚球源数据
	 * @param marketID
	 *            投注盘类型 0香港盘 1印尼盘 2马来盘 3欧洲盘
	 * @param showior
	 *            显示位数
	 * @param iorpoints
	 *            赔率小数点位数
	 * @return
	 */
	private List<Playinfo> parsePASSOddsData(List<Playinfo> playinfos,String gameCode,String itemType, JSONArray lineArray, int marketID, String showior, String iorpoints) throws Exception {
		
		Integer[] ONETWO = null;
		Integer[] ALLOW = null;
		Integer[] STANDARD = null;
		Integer[] BIGSMALL = null;
		Integer[] HF_ALLOW = null;
		Integer[] HF_BIGSMALL = null;
		Integer[] HF_STANDARD = null;
		
		
		int ALL_STANDARD = 0;
		
		String hostName = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_MATCH_HOST_NAME);
		int gametiem = findGameTime(hostName, gameCode);
		
		if(SnatchConstant.FOOTBALL.equals(gameCode)){
			ALL_STANDARD = HgConstant.PLAY_TYPE_ALL_STANDARD;
			ALLOW = HgConstant.PASS_PLAY_ALLOW_WAY;
			ONETWO = HgConstant.PASS_PLAY_ONETWO_HOST_RATIO;
			STANDARD = HgConstant.PASS_PLAY_STANDARD_HOST_RATIO;
			BIGSMALL = HgConstant.PASS_PLAY_BIGSMALL_HOST_TRADINGITEM_NAME;
			HF_ALLOW = HgConstant.PASS_PLAY_ALLOW_WAY_HALF;
			HF_BIGSMALL = HgConstant.PASS_PLAY_BIGSMALL_HOST_TRADINGITEM_NAME_HALF;
			HF_STANDARD = HgConstant.PASS_PLAY_STANDARD_HOST_RATIO_HALF;
			
		}else if(SnatchConstant.BASKETBALL.equals(gameCode)){
			ALLOW = HgConstant.PASS_PLAY_ALLOW_WAY;
			STANDARD = HgConstant.PASS_PLAY_STANDARD_HOST_RATIO;
			BIGSMALL = HgConstant.PASS_PLAY_BIGSMALL_HOST_TRADINGITEM_NAME;
			ONETWO = HgConstant.PASS_PLAY_ONETWO_HOST_RATIO;
				
		}else if(SnatchConstant.TENNIS.equals(gameCode)){
			ALLOW = HgConstant.PASS_PLAY_ALLOW_WAY;
			BIGSMALL = HgConstant.PASS_PLAY_BIGSMALL_HOST_TRADINGITEM_NAME;
		}else if(SnatchConstant.VOLLEYBALL.equals(gameCode)){
			ALLOW = HgConstant.PASS_PLAY_ALLOW_WAY;
		}else if(SnatchConstant.BASEBALL.equals(gameCode)){
			ALLOW = HgConstant.PASS_PLAY_ALLOW_WAY;
			BIGSMALL = HgConstant.PASS_PLAY_BIGSMALL_HOST_TRADINGITEM_NAME;
		}else if(SnatchConstant.BASEBALL.equals(gameCode)){
			ALLOW = HgConstant.PASS_PLAY_ALLOW_WAY;
			BIGSMALL = HgConstant.PASS_PLAY_BIGSMALL_HOST_TRADINGITEM_NAME;
			ONETWO = HgConstant.PASS_PLAY_ONETWO_HOST_RATIO;
		}else if(SnatchConstant.OTHER.equals(gameCode)){
			ALLOW = HgConstant.PASS_PLAY_ALLOW_WAY;
			STANDARD = HgConstant.PASS_PLAY_STANDARD_HOST_RATIO;
			BIGSMALL = HgConstant.PASS_PLAY_BIGSMALL_HOST_TRADINGITEM_NAME;
			ONETWO = HgConstant.PASS_PLAY_ONETWO_HOST_RATIO;
		}
		
		//全场单双
		
		Playinfo onetwof = parseOnetwollPlayinfo(lineArray, ONETWO,gametiem,HgConstant.PLAY_TYPE_ALL_ONETWO, marketID, showior, iorpoints);
		if(null != onetwof){
			onetwof.setBunch(true);
			onetwof.getTradingItems().clear();  //过关的赔率清空
			playinfos .add(onetwof);
		}
		
		//全场让球
		Playinfo allowf = parseAllowPlayinfo(lineArray, ALLOW,gametiem, HgConstant.PLAY_TYPE_ALL_ALLOW, marketID, showior, iorpoints);
		if(null != allowf){
			allowf.setBunch(true);
			allowf.getTradingItems().clear();  //过关的赔率清空
			playinfos .add(allowf);
		}
		
		//全场大小球
		Playinfo bigsmallf = parseBigsmallPlayinfo(lineArray, BIGSMALL,gametiem,  HgConstant.PLAY_TYPE_ALL_BIGSMALL,true, marketID, showior, iorpoints);
		if(null != bigsmallf){
			bigsmallf.setBunch(true);
			bigsmallf.getTradingItems().clear();  //过关的赔率清空
			playinfos .add(bigsmallf);
		}
		
		//全场标准盘
		Playinfo standardf = parseStandardPlayinfo(lineArray, STANDARD,gametiem, ALL_STANDARD,SnatchConstant.FOOTBALL.equals(gameCode)?true:false, marketID, showior, iorpoints);
		if(null != standardf){
			standardf.setBunch(true);
			standardf.getTradingItems().clear();  //过关的赔率清空
			playinfos .add(standardf);
		}
		
		//上半场让球
		Playinfo allowh = parseAllowPlayinfo(lineArray,HF_ALLOW,gametiem, HgConstant.PLAY_TYPE_HALF_ALLOW, marketID, showior, iorpoints);
		if(null != allowh){
			allowh.setBunch(true);
			allowh.getTradingItems().clear();  //过关的赔率清空
			playinfos .add(allowh);
		}
		//上半场大小球
		Playinfo bigsmallh = parseBigsmallPlayinfo(lineArray,HF_BIGSMALL,gametiem, HgConstant.PLAY_TYPE_HALF_BIGSMALL,true, marketID, showior, iorpoints);
		if(null != bigsmallh){
			bigsmallh.setBunch(true);
			bigsmallh.getTradingItems().clear();  //过关的赔率清空
			playinfos .add(bigsmallh);
		}
		
		//上半场标准盘
		Playinfo standardh = parseStandardPlayinfo(lineArray, HF_STANDARD,gametiem,  HgConstant.PLAY_TYPE_HALF_STANDARD,true, marketID, showior, iorpoints);
		if(null != standardh){
			standardh.setBunch(true);
			standardh.getTradingItems().clear();  //过关的赔率清空
			playinfos .add(standardh);
		}
		if(SnatchConstant.FOOTBALL.equals(gameCode)){
			playinfos = findPassPlay(playinfos, lineArray);
		}
			
		
		return playinfos;
		
		
	}
	
	
	
	private List<Playinfo> findPassPlay(List<Playinfo> playinfos,JSONArray lineArray){
		//全场波胆
		String ft_10 = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.PASS_PLAY_FT_CS_10_RATIO);
		String ft_21 = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.PASS_PLAY_FT_CS_21_RATIO);
		String ft_22 = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.PASS_PLAY_FT_CS_22_RATIO);
		
		if(!StringUtils.isNullZero(ft_10) && !StringUtils.isNullZero(ft_21) && !StringUtils.isNullZero(ft_22) ){
			Playinfo play  = new Playinfo();
			play.setBunch(true);
			// 设置玩法名称
			play.setName(SnatchConstant.FTCS);
			// 设置全场(1)或上半场(2)
			play.setGametime(1);
			playinfos.add(play);
		}
			
		//半场波胆
		String ft_hf_10 = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.PASS_PLAY_FT_HF_10_RATIO);
		String ft_hf_21 = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.PASS_PLAY_FT_HF_21_RATIO);
		String ft_hf_22 = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.PASS_PLAY_FT_HF_22_RATIO);
		
		if(!StringUtils.isNullZero(ft_hf_10) && !StringUtils.isNullZero(ft_hf_21) && !StringUtils.isNullZero(ft_hf_22) ){
			Playinfo play  = new Playinfo();
			play.setBunch(true);
			// 设置玩法名称
			play.setName(SnatchConstant.FTCS);
			// 设置全场(1)或上半场(2)
			play.setGametime(2);
			playinfos.add(play);
		}
		
		//总入球
		String tg_01 = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.PASS_PLAY_TG_0_1_RATIO);
		String tg_23 = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.PASS_PLAY_TG_2_3_RATIO);
		String tg_46 = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.PASS_PLAY_TG_4_6_RATIO);
		
		if(!StringUtils.isNullZero(tg_01) && !StringUtils.isNullZero(tg_23) && !StringUtils.isNullZero(tg_46) ){
			Playinfo play  = new Playinfo();
			play.setBunch(true);
			// 设置玩法名称
			play.setName(SnatchConstant.TG);
			// 设置全场(1)或上半场(2)
			play.setGametime(1);
			playinfos.add(play);
		}
			
		
		//半全场
		String htft_hh= HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.PASS_PLAY_HTFT_HH_RATIO);
		String htft_hd = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.PASS_PLAY_HTFT_HD_RATIO);
		String htft_ha = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.PASS_PLAY_HTFT_HA_RATIO);
		
		if(!StringUtils.isNullZero(htft_hh) && !StringUtils.isNullZero(htft_hd) && !StringUtils.isNullZero(htft_ha) ){
			Playinfo play  = new Playinfo();
			play.setBunch(true);
			// 设置玩法名称
			play.setName(SnatchConstant.HTFT);
			// 设置全场(1)或上半场(2)
			play.setGametime(1);
			playinfos.add(play);
		}
		
		return playinfos;
	}
	
	/**
	 * 解析皇冠冠军赔率数据
	 * 
	 * @param playinfos
	 *            玩法列表
	 * @param lineArray
	 *            需要解析的滚球源数据
	 * @param marketID
	 *            投注盘类型 0香港盘 1印尼盘 2马来盘 3欧洲盘
	 * @param showior
	 *            显示位数
	 * @param iorpoints
	 *            赔率小数点位数
	 * @return
	 */
	private List<Playinfo> parseFIRSTOddsData(List<Playinfo> playinfos, JSONArray lineArray, int marketID, String showior, String iorpoints) throws Exception {
		// 玩法信息
		Playinfo playinfo = new Playinfo();
		playinfo.setGametime(HgUtil.getGameTime(HgConstant.PLAY_TYPE_FIRST));
		// 设置玩法名称
		playinfo.setName(SnatchConstant.FIRST);
		// playinfo.setSelfID(playId);// 玩法id(这里放的是全场或上半场的id)
		// 设置全场(1)或上半场(2)

		List<TradingItem> tradingItems = new ArrayList<TradingItem>();// 交易项列表

		Integer number = HttpUtil.getJsonArrayIntValue(lineArray, HgConstant.FIRST_PLAY_NUMBER);
		for(int i=0;i<number;i++){
			TradingItem tradingItem = new TradingItem();
			tradingItem.setName(HttpUtil.getJsonArrayStringShift(lineArray, HgConstant.FIRST_PLAY_NAME,HgConstant.FIRST_SHIFT_NUMBER*i));
			tradingItem.setRatio(HttpUtil.getJsonArrayDoubleShift(lineArray, HgConstant.FIRST_PLAY_RATIO, HgConstant.FIRST_SHIFT_NUMBER*i));
			tradingItems.add(tradingItem);
		}
		playinfo.setTradingItems(tradingItems);
		playinfos.add(playinfo);
		return playinfos;
	}

	/**
	
	
	/**
	 * 解析皇冠玩法信息
	 * 
	 * @param playType
	 *            1 全场让球盘 2 全场单双盘 3 全场大小盘 5 全场标准盘 7 半场让球盘 8 半场标准盘 9 半场大小盘
	 * @param playId
	 *            玩法id
	 * @param hostRatio
	 *            主队赔率
	 * @param customerRatio
	 *            客队赔率
	 * @param thirdRatio
	 *            标准盘时的和局赔率
	 * @param allowNum
	 *            让球盘时的让球数/大小球或单双盘主队交易项
	 * @param allowWay
	 *            让球盘时的让球方/大小球或单双盘客队交易项
	 * @param hostTradingItemId
	 *            主队交易项id
	 * @param customerTradingItemId
	 *            客队交易项id
	 * @return
	 */
	private Playinfo getPlayinfo(int playType, String playId,int gameTime, double hostRatio, double customerRatio, double thirdRatio, String allowNum, String allowWay,
			String hostTradingItemId, String customerTradingItemId) {
		// 玩法信息
		Playinfo playinfo = new Playinfo();
		if(0 == gameTime){
			gameTime = HgUtil.getGameTime(playType);
		}
		// 设置玩法名称
		playinfo.setName(HgUtil.getPlayName(playType));
		// playinfo.setSelfID(playId);// 玩法id(这里放的是全场或上半场的id)
		// 设置全场(1)或上半场(2)
		playinfo.setGametime(gameTime);

		List<TradingItem> tradingItems = new ArrayList<TradingItem>();// 交易项列表

		TradingItem hostTradingItem = new TradingItem();// 主队交易项对象
		TradingItem customerTradingItem = new TradingItem();// 客队交易项对象
		TradingItem thirdTradingItem = null;// 标准盘时的和交易项的对象

		switch (playType) {
		case HgConstant.PLAY_TYPE_ALL_ALLOW: // 全场让球盘
		case HgConstant.PLAY_TYPE_HALF_ALLOW: // 上半场让球盘
			allowNum = HgUtil.dealTradingItem(allowNum);
			playinfo.setHandicap(findallowHacp(allowWay, allowNum, 0));
			hostTradingItem.setName(findallowHacp(allowWay, allowNum, 1));// 交易项名称
			customerTradingItem.setName(findallowHacp(allowWay, allowNum, 2));
			
			hostTradingItem.setRatio(hostRatio);// 交易项赔率
			customerTradingItem.setRatio(customerRatio);
			break;
		case HgConstant.PLAY_TYPE_ALL_ONETWO: // 全场单双盘
			// 单 赔率
			hostTradingItem.setName(allowNum);
			hostTradingItem.setRatio(hostRatio);
			// 双 赔率
			customerTradingItem.setName(allowWay);
			customerTradingItem.setRatio(customerRatio);
			break;
		case HgConstant.PLAY_TYPE_ALL_BIGSMALL: // 全场大小球
		case HgConstant.PLAY_TYPE_HALF_BIGSMALL: // 上半场大小球
		case HgConstant. PLAY_TYPE_BASKET_ALL_BIGSMALL_HOST: // 主队大小球
		case HgConstant. PLAY_TYPE_BASKET_ALL_BIGSMALL_AWAY: // 客队大小球
			allowNum = HgUtil.dealTradingItem(allowNum);
			playinfo.setHandicap(HgUtil.dealPlayHandicap(allowNum));
			allowWay = HgUtil.dealTradingItem(allowWay);

			// 大 赔率
			hostTradingItem.setName(allowNum.replace("O", SnatchConstant.BIGSMALL_BIG));
			hostTradingItem.setRatio(hostRatio);

			// 小 赔率
			customerTradingItem.setName(allowWay.replace("U", SnatchConstant.BIGSMALL_SMALL));
			customerTradingItem.setRatio(customerRatio);
			
			break;
		case HgConstant.PLAY_TYPE_ALL_STANDARD: // 全场标准盘
		case HgConstant.PLAY_TYPE_HALF_STANDARD: // 上半场标准盘
			// 主胜 赔率
			hostTradingItem.setName(SnatchConstant.STANDARD_HOME_WIN);
			hostTradingItem.setRatio(hostRatio);

			// 客胜 赔率
			customerTradingItem.setName(SnatchConstant.STANDARD_AWAY_WIN);
			customerTradingItem.setRatio(customerRatio);

			// 和 赔率
			thirdTradingItem = new TradingItem();
			thirdTradingItem.setName(SnatchConstant.STANDARD_DRAW);
			thirdTradingItem.setRatio(thirdRatio);
			
			break;
		case HgConstant.PLAY_TYPE_BASKET_ALL_STANDARD: // 上半场标准盘
			// 主胜 赔率
			hostTradingItem.setName(SnatchConstant.STANDARD_HOME_WIN);
			hostTradingItem.setRatio(hostRatio);

			// 客胜 赔率
			customerTradingItem.setName(SnatchConstant.STANDARD_AWAY_WIN);
			customerTradingItem.setRatio(customerRatio);

			break;
		default:
			break;
		}
		
		if(null != playId){
			hostTradingItem.setSelfID(HttpUtil.unicode2Ascii("gid=" + playId + "&gnum=" + customerTradingItemId));
			customerTradingItem.setSelfID(HttpUtil.unicode2Ascii("gid=" + playId + "&gnum=" + hostTradingItemId));
			if(null != thirdTradingItem){
				thirdTradingItem.setSelfID(HttpUtil.unicode2Ascii("gid=" + playId + "&gnum=" + customerTradingItemId));
			}
		}
		
		tradingItems.add(hostTradingItem);
		tradingItems.add(customerTradingItem);
		if (null != thirdTradingItem) {
			tradingItems.add(thirdTradingItem);
		}

		playinfo.setTradingItems(tradingItems);

		return playinfo;
	}

	/**
	 * 解析皇冠总入球赔率数据
	 * 
	 * @param playinfos
	 *            玩法列表
	 * @param lineArray
	 *            需要解析的单式源数据
	 * @return
	 * @throws Exception
	 */
	private List<Playinfo> parseTGOddsData(List<Playinfo> playinfos, JSONArray lineArray,String itemType) throws Exception {
		// 玩法信息
		Playinfo playinfo = new Playinfo();
		playinfo.setGametime(HgUtil.getGameTime(HgConstant.PLAY_TYPE_TG));
		// 设置玩法名称(总入球)
		playinfo.setName(SnatchConstant.TG);

		String gid = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_PLAY_TYPE_ALL_ID);

		double tg_0_1_ratio = 0;
		if(SnatchConstant.SNATCH_TYPE_GQ.equals(itemType)){
			tg_0_1_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_TG_GQ_0_1_RATIO);
		}else{
			tg_0_1_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_TG_0_1_RATIO);
		}
		playinfo.getTradingItems().add(getTGPlayinfo(1, gid, tg_0_1_ratio));
		
		double tg_2_3_ratio = 0;
		if(SnatchConstant.SNATCH_TYPE_GQ.equals(itemType)){
			tg_2_3_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_TG_GQ_2_3_RATIO);
		}else{
			tg_2_3_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_TG_2_3_RATIO);
		}
		
		playinfo.getTradingItems().add(getTGPlayinfo(2, gid, tg_2_3_ratio));

		double tg_4_6_ratio = 0;
		if(SnatchConstant.SNATCH_TYPE_GQ.equals(itemType)){
			tg_4_6_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_TG_GQ_4_6_RATIO);
		}else{
			tg_4_6_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_TG_4_6_RATIO);
		}
		playinfo.getTradingItems().add(getTGPlayinfo(3, gid, tg_4_6_ratio));

		double tg_7_over_ratio = 0;
		if(SnatchConstant.SNATCH_TYPE_GQ.equals(itemType)){
			tg_7_over_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_TG_GQ_7_OVER_RATIO);
		}else{
			tg_7_over_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_TG_7_OVER_RATIO);
		}
		playinfo.getTradingItems().add(getTGPlayinfo(4, gid, tg_7_over_ratio));
		
		playinfos.add(playinfo);

		return playinfos;
	}

	/**
	 * 解析总入球玩法信息
	 * 
	 * @param playType
	 *            1 (0-1) 2 (2-3) 3 (4-6) 4 (7&over)
	 * @param gid
	 *            交易项id
	 * @param ratio
	 *            赔率
	 * @return
	 */
	private TradingItem getTGPlayinfo(int playType, String gid, double ratio) {
		/*// 玩法信息
		Playinfo playinfo = new Playinfo();

		// 设置玩法名称(总入球)
		playinfo.setName(SnatchConstant.TG);*/


		TradingItem tradingItem = new TradingItem();// 交易项对象

		tradingItem.setSelfID(gid);

		switch (playType) {
		case 1: // 0-1
			tradingItem.setName(SnatchConstant.TG_0_1);
			break;
		case 2: // 2-3
			tradingItem.setName(SnatchConstant.TG_2_3);
			break;
		case 3: // 4-6
			tradingItem.setName(SnatchConstant.TG_4_6);
			break;
		case 4: // 7&over
			tradingItem.setName(SnatchConstant.TG_7_OVER);
			break;
		default:
			break;
		}

		tradingItem.setRatio(ratio);


		return tradingItem;
	}

	/**
	 * 解析皇冠半场/全场赔率数据
	 * 
	 * @param playinfos
	 *            玩法列表
	 * @param lineArray
	 *            需要解析的单式源数据
	 * @return
	 * @throws Exception
	 */
	private List<Playinfo> parseHTFTOddsData(List<Playinfo> playinfos, JSONArray lineArray) throws Exception {
		// 玩法信息
		Playinfo playinfo = new Playinfo();
		playinfo.setGametime(HgUtil.getGameTime(HgConstant.PLAY_TYPE_HTFT));
		playinfo.setName(SnatchConstant.HTFT);

		String gid = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_PLAY_TYPE_ALL_ID);

		double htft_hh_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_HTFT_HH_RATIO);
		playinfo.getTradingItems().add(getHTFTPlayinfo(1, gid, htft_hh_ratio));

		double htft_hd_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_HTFT_HD_RATIO);
		playinfo.getTradingItems().add(getHTFTPlayinfo(2, gid, htft_hd_ratio));

		double htft_ha_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_HTFT_HA_RATIO);
		playinfo.getTradingItems().add(getHTFTPlayinfo(3, gid, htft_ha_ratio));

		double htft_dh_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_HTFT_DH_RATIO);
		playinfo.getTradingItems().add(getHTFTPlayinfo(4, gid, htft_dh_ratio));

		double htft_dd_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_HTFT_DD_RATIO);
		playinfo.getTradingItems().add(getHTFTPlayinfo(5, gid, htft_dd_ratio));

		double htft_da_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_HTFT_DA_RATIO);
		playinfo.getTradingItems().add(getHTFTPlayinfo(6, gid, htft_da_ratio));

		double htft_ah_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_HTFT_AH_RATIO);
		playinfo.getTradingItems().add(getHTFTPlayinfo(7, gid, htft_ah_ratio));

		double htft_ad_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_HTFT_AD_RATIO);
		playinfo.getTradingItems().add(getHTFTPlayinfo(8, gid, htft_ad_ratio));

		double htft_aa_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_HTFT_AA_RATIO);
		playinfo.getTradingItems().add(getHTFTPlayinfo(9, gid, htft_aa_ratio));
		
		playinfos.add(playinfo);
		return playinfos;
	}

	/**
	 * 解析半场/全场玩法信息
	 * 
	 * @param playType
	 *            1 主-主 2 主-和 3 主-客 4 和-主 5 和-和 6 和-客 7 客-主 8 客-和 9 客-客
	 * @param gid
	 *            交易项id
	 * @param ratio
	 *            赔率
	 * @return
	 */
	private TradingItem getHTFTPlayinfo(int playType, String gid, double ratio) {
		// 玩法信息

		// 设置玩法名称(半场/全场)
		/*playinfo.setName(SnatchConstant.HTFT);*/


		TradingItem tradingItem = new TradingItem();// 交易项对象

		tradingItem.setSelfID(gid);

		switch (playType) {
		case 1: // 主-主
			tradingItem.setName(SnatchConstant.HTFT_HH);
			break;
		case 2: // 主-和
			tradingItem.setName(SnatchConstant.HTFT_HD);
			break;
		case 3: // 主-客
			tradingItem.setName(SnatchConstant.HTFT_HA);
			break;
		case 4: // 和-主
			tradingItem.setName(SnatchConstant.HTFT_DH);
			break;
		case 5: // 和-和
			tradingItem.setName(SnatchConstant.HTFT_DD);
			break;
		case 6: // 和-客
			tradingItem.setName(SnatchConstant.HTFT_DA);
			break;
		case 7: // 客-主
			tradingItem.setName(SnatchConstant.HTFT_AH);
			break;
		case 8: // 客-和
			tradingItem.setName(SnatchConstant.HTFT_AD);
			break;
		case 9: // 客-客
			tradingItem.setName(SnatchConstant.HTFT_AA);
			break;
		default:
			break;
		}

		tradingItem.setRatio(ratio);



		return tradingItem;
	}

	/**
	 * 解析皇冠波胆赔率数据
	 * 
	 * @param playinfos
	 *            玩法列表
	 * @param lineArray
	 *            需要解析的单式源数据
	 * @return
	 * @throws Exception
	 */
	private List<Playinfo> parseCSOddsData(String snatchItem,List<Playinfo> playinfos, JSONArray lineArray) throws Exception {
		// 玩法信息
		Playinfo playinfo = new Playinfo();
		playinfo.setName(SnatchConstant.FTCS);
		if(SnatchConstant.HG_SNATCH_ITEM_FTCS.equals(snatchItem)){
			playinfo.setGametime(HgUtil.getGameTime(HgConstant.PLAY_TYPE_FT));
		}else{
			playinfo.setGametime(HgUtil.getGameTime(HgConstant.PLAY_TYPE_FT_HF));
		}
		
		String gid = HttpUtil.getJsonArrayStringValue(lineArray, HgConstant.ARRAY_PLAY_TYPE_ALL_ID);

		double cs_10_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_CS_10_RATIO);
		playinfo.getTradingItems().add(getCSPlayinfo(1, gid, cs_10_ratio));

		double cs_20_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_CS_20_RATIO);
		playinfo.getTradingItems().add(getCSPlayinfo(2, gid, cs_20_ratio));
		 

		double cs_21_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_CS_21_RATIO);
		playinfo.getTradingItems().add(getCSPlayinfo(3, gid, cs_21_ratio));
		 

		double cs_30_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_CS_30_RATIO);
		playinfo.getTradingItems().add(getCSPlayinfo(4, gid, cs_30_ratio));
		 

		double cs_31_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_CS_31_RATIO);
		playinfo.getTradingItems().add(getCSPlayinfo(5, gid, cs_31_ratio));
		 

		double cs_32_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_CS_32_RATIO);
		playinfo.getTradingItems().add(getCSPlayinfo(6, gid, cs_32_ratio));
		 

		if (SnatchConstant.HG_SNATCH_ITEM_FTCS.equals(snatchItem)) {// 下面交易项只有全场波胆才有的
			double cs_40_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_FT_CS_40_RATIO);
			playinfo.getTradingItems().add(getCSPlayinfo(7, gid, cs_40_ratio));
			 

			double cs_41_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_FT_CS_41_RATIO);
			playinfo.getTradingItems().add(getCSPlayinfo(8, gid, cs_41_ratio));
			 

			double cs_42_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_FT_CS_42_RATIO);
			playinfo.getTradingItems().add(getCSPlayinfo(9, gid, cs_42_ratio));
			 

			double cs_43_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_FT_CS_43_RATIO);
			playinfo.getTradingItems().add(getCSPlayinfo(10, gid, cs_43_ratio));
			 
		}

		double cs_01_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_CS_01_RATIO);
		playinfo.getTradingItems().add(getCSPlayinfo(11, gid, cs_01_ratio));
		 

		double cs_02_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_CS_02_RATIO);
		playinfo.getTradingItems().add(getCSPlayinfo(12, gid, cs_02_ratio));
		 

		double cs_12_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_CS_12_RATIO);
		playinfo.getTradingItems().add(getCSPlayinfo(13, gid, cs_12_ratio));
		 

		double cs_03_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_CS_03_RATIO);
		playinfo.getTradingItems().add(getCSPlayinfo(14, gid, cs_03_ratio));
		 

		double cs_13_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_CS_13_RATIO);
		playinfo.getTradingItems().add(getCSPlayinfo(15, gid, cs_13_ratio));
		 

		double cs_23_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_CS_23_RATIO);
		playinfo.getTradingItems().add(getCSPlayinfo(16, gid, cs_23_ratio));
		 

		if (SnatchConstant.HG_SNATCH_ITEM_FTCS.equals(snatchItem)) {// 下面交易项只有全场波胆才有的
			double cs_04_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_FT_CS_04_RATIO);
			playinfo.getTradingItems().add(getCSPlayinfo(17, gid, cs_04_ratio));
			 

			double cs_14_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_FT_CS_14_RATIO);
			playinfo.getTradingItems().add(getCSPlayinfo(18, gid, cs_14_ratio));
			 

			double cs_24_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_FT_CS_24_RATIO);
			playinfo.getTradingItems().add(getCSPlayinfo(19, gid, cs_24_ratio));
			 

			double cs_34_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_FT_CS_34_RATIO);
			playinfo.getTradingItems().add(getCSPlayinfo(20, gid, cs_34_ratio));
			 
		}

		double cs_00_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_CS_00_RATIO);
		playinfo.getTradingItems().add(getCSPlayinfo(21, gid, cs_00_ratio));
		 

		double cs_11_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_CS_11_RATIO);
		playinfo.getTradingItems().add(getCSPlayinfo(22, gid, cs_11_ratio));
		 

		double cs_22_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_CS_22_RATIO);
		playinfo.getTradingItems().add(getCSPlayinfo(23, gid, cs_22_ratio));
		 

		double cs_33_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_CS_33_RATIO);
		playinfo.getTradingItems().add(getCSPlayinfo(24, gid, cs_33_ratio));
		 

		if (SnatchConstant.HG_SNATCH_ITEM_FTCS.equals(snatchItem)) {// 下面交易项只有全场波胆才有的
			double cs_44_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_FT_CS_44_RATIO);
			playinfo.getTradingItems().add(getCSPlayinfo(25, gid, cs_44_ratio));
			 
		}

		double cs_other_ratio = HttpUtil.getJsonArrayDoubleValue(lineArray, HgConstant.ARRAY_PLAY_CS_OTHER_RATIO);
		playinfo.getTradingItems().add(getCSPlayinfo(26, gid, cs_other_ratio));
		
		playinfos.add(playinfo);

		return playinfos;
	}

	/**
	 * 解析波胆玩法信息
	 * 
	 * @param playType
	 *            1 (1:0) 2 (2:0) 3 (2:1) 4 (3:0) 5 (3:1) 6 (3:2) 7 (4:0) 8 (4:1) 9 (4:2) 10 (4:3) 11 (0:1) 12 (0:2) 13 (1:2) 14 (0:3) 15 (1:3) 16 (2:3) 17
	 *            (0:4) 18 (1:4) 19 (2:4) 20 (3:4) 21 (0:0) 22 (1:1) 23 (2:2) 24 (3:3) 25 (4:4) 26 (其他)
	 * @param gid
	 *            交易项id
	 * @param ratio
	 *            赔率
	 * @return
	 */
	private TradingItem getCSPlayinfo(int playType, String gid, double ratio) {
		// 玩法信息

		TradingItem tradingItem = new TradingItem();// 交易项对象
		tradingItem.setRatio(ratio);
		tradingItem.setSelfID(gid);

		switch (playType) {
		case 1: // 1:0
			tradingItem.setName(SnatchConstant.CS_10);
			break;
		case 2: // 2:0
			tradingItem.setName(SnatchConstant.CS_20);
			break;
		case 3: // 2:1
			tradingItem.setName(SnatchConstant.CS_21);
			break;
		case 4: // 3:0
			tradingItem.setName(SnatchConstant.CS_30);
			break;
		case 5: // 3:1
			tradingItem.setName(SnatchConstant.CS_31);
			break;
		case 6: // 3:2
			tradingItem.setName(SnatchConstant.CS_32);
			break;
		case 7: // 4:0
			tradingItem.setName(SnatchConstant.CS_40);
			break;
		case 8: // 4:1
			tradingItem.setName(SnatchConstant.CS_41);
			break;
		case 9: // 4:2
			tradingItem.setName(SnatchConstant.CS_42);
			break;
		case 10: // 4:3
			tradingItem.setName(SnatchConstant.CS_43);
			break;
		case 11: // 0:1
			tradingItem.setName(SnatchConstant.CS_01);
			break;
		case 12: // 0:2
			tradingItem.setName(SnatchConstant.CS_02);
			break;
		case 13: // 1:2
			tradingItem.setName(SnatchConstant.CS_12);
			break;
		case 14: // 0:3
			tradingItem.setName(SnatchConstant.CS_03);
			break;
		case 15: // 1:3
			tradingItem.setName(SnatchConstant.CS_13);
			break;
		case 16: // 2:3
			tradingItem.setName(SnatchConstant.CS_23);
			break;
		case 17: // 0:4
			tradingItem.setName(SnatchConstant.CS_04);
			break;
		case 18: // 1:4
			tradingItem.setName(SnatchConstant.CS_14);
			break;
		case 19: // 2:4
			tradingItem.setName(SnatchConstant.CS_24);
			break;
		case 20: // 3:4
			tradingItem.setName(SnatchConstant.CS_34);
			break;
		case 21: // 0:0
			tradingItem.setName(SnatchConstant.CS_00);
			break;
		case 22: // 1:1
			tradingItem.setName(SnatchConstant.CS_11);
			break;
		case 23: // 2:2
			tradingItem.setName(SnatchConstant.CS_22);
			break;
		case 24: // 3:3
			tradingItem.setName(SnatchConstant.CS_33);
			break;
		case 25: // 4:4
			tradingItem.setName(SnatchConstant.CS_44);
			break;
		case 26: // 其他
			tradingItem.setName(SnatchConstant.CS_OTHER);
			break;
		default:
			break;
		}

		return tradingItem;
	}
	
	/**
	 * 
	 * @param allowWay
	 * @param allowNum
	 * @param itemtype 0 玩法 1为主队 2为客队
	 * @return
	 */
	private String findallowHacp(String allowWay,String allowNum,int itemtype){
		//allowNum = HgUtil.dealTradingItem(allowNum);
		boolean isZero = HttpUtil.isZeroRatio(allowNum);
		// 主|客队 赔率
		if (isZero) {
			if(0==itemtype){
				return "H"+"(" + allowNum + ")";
			}else if(1==itemtype){
				return SnatchConstant.ALLOW_HOME + "(" + allowNum + ")";
			}else{
				return SnatchConstant.ALLOW_AWAY_BEEN + "(" + allowNum + ")";
			}
		} else {
			if ("H".equals(allowWay)) {
				if(0==itemtype){
					return  allowWay+"(" + allowNum + ")";
				}else if(1==itemtype){
					return SnatchConstant.ALLOW_HOME + "(" + allowNum + ")";
				}else{
					return SnatchConstant.ALLOW_AWAY_BEEN + "(" + allowNum + ")";
				}
			} else {
				if(0==itemtype){
					return  allowWay+"(" + allowNum + ")";
				}else if(1==itemtype){
					return SnatchConstant.ALLOW_HOME_BEEN + "(" + allowNum + ")";
				}else{
					return SnatchConstant.ALLOW_AWAY + "(" + allowNum + ")";
				}
			}
		}
	}
	

	/**************************** 让球****************************/
	private Playinfo parseAllowPlayinfo(JSONArray lineArray,Integer[]  playindex,int gameTime,int playType,int marketID, String showior, String iorpoints) throws Exception{
		
		Playinfo playinfo = null;
		if(null == playindex) return null;
		// 让球方
		String allowWay = HttpUtil.getJsonArrayStringValue(lineArray, playindex);
		// 让球个数
		String allowNum = HttpUtil.getJsonArrayStringShift(lineArray, playindex,1);
		if(HttpUtil.isNull(allowNum)) return playinfo;
		// 让球盘主队赔率
		Double hostRation = HttpUtil.getJsonArrayDoubleShift(lineArray, playindex,2);
		// 让球盘客队赔率
		Double customerRation = HttpUtil.getJsonArrayDoubleShift(lineArray, playindex,3);
		String allowRatio[] = HgUtil.get_other_ioratio(marketID, hostRation, customerRation, showior, iorpoints);
		if (!HttpUtil.isNull(allowNum)) {
			playinfo = getPlayinfo(playType, null, gameTime,Double.parseDouble(allowRatio[0]), Double.parseDouble(allowRatio[1]), 0, allowNum, allowWay, null, null);
			}
		return playinfo;
	}
	
	/**************************** 大小球 ****************************/
	private Playinfo parseBigsmallPlayinfo(JSONArray lineArray,Integer[]  playindex,int gameTime,int playType,boolean isasc,int marketID, String showior, String iorpoints) throws Exception{
		
		Playinfo playinfo = null;
		if(null == playindex) return null;
		// 大小盘主队交易项
		String hostTradingItem = HttpUtil.getJsonArrayStringValue(lineArray, playindex);
		if(HttpUtil.isNull(hostTradingItem)) return playinfo;

		// 大小盘主队赔率
		Double hostRation = HttpUtil.getJsonArrayDoubleShift(lineArray, playindex,isasc?2:3);

		// 大小盘客队交易项
		String customerTradingItem = HttpUtil.getJsonArrayStringShift(lineArray, playindex,1);

		// 大小盘客队赔率
		Double customerRation = HttpUtil.getJsonArrayDoubleShift(lineArray, playindex,isasc?3:2);

		String bigsmallRatio[] = HgUtil.get_other_ioratio(marketID, customerRation, hostRation, showior, iorpoints);
		if (!HttpUtil.isNull(hostTradingItem) && !HttpUtil.isNull(customerTradingItem)) {
			playinfo = getPlayinfo(playType, null, gameTime, Double.parseDouble(bigsmallRatio[1]), Double.parseDouble(bigsmallRatio[0]), 0, hostTradingItem, customerTradingItem, null, null);
		}
		return playinfo;
	}
	
	/****************************单双****************************/
	private Playinfo parseOnetwollPlayinfo(JSONArray lineArray,Integer[]  playindex,int gameTime,int playType,int marketID, String showior, String iorpoints) throws Exception{
		
		Playinfo playinfo = null;
		if(null == playindex) return null;
		
		// 大小盘主队赔率
		Double hostRation = HttpUtil.getJsonArrayDoubleValue(lineArray, playindex);
		// 大小盘客队赔率
		Double customerRation = HttpUtil.getJsonArrayDoubleShift(lineArray, playindex,1);
		
		if (0 != hostRation && 0 != customerRation) {
			hostRation = HgUtil.tranOddsByOddsType(marketID, hostRation, Integer.parseInt(iorpoints));
			customerRation = HgUtil.tranOddsByOddsType(marketID, customerRation, Integer.parseInt(iorpoints));
			
			playinfo = getPlayinfo(playType, null, gameTime, hostRation, customerRation, 0, "单", "双", null, null);
		}
		return playinfo;
	}
	/**************************** 标准盘 ****************************/
	private Playinfo parseStandardPlayinfo(JSONArray lineArray,Integer[]  playindex,int gameTime,int playType,boolean isthird,int marketID, String showior, String iorpoints) throws Exception{
		Playinfo playinfo = null;
		if(null == playindex) return null;
		String thirdRatioStr = null;
		// 标准盘主队赔率
		String hostRationStr = HttpUtil.getJsonArrayStringValue(lineArray, playindex);
		if(HttpUtil.isNull(hostRationStr)) return playinfo;
		// 标准盘客队赔率
		String customerRationStr = HttpUtil.getJsonArrayStringShift(lineArray, playindex,1);
		if(isthird){
			// 标准盘和赔率
			thirdRatioStr = HttpUtil.getJsonArrayStringShift(lineArray, playindex,2);
		}

		if (!HttpUtil.isNull(hostRationStr) && !HttpUtil.isNull(customerRationStr) && (!HttpUtil.isNull(thirdRatioStr) || !isthird)) {
			playinfo = getPlayinfo(playType, null, gameTime, Double.valueOf(hostRationStr),  Double.valueOf(customerRationStr), (null == thirdRatioStr?0:Double.valueOf(thirdRatioStr)), "", "", null, null);
		}
		return playinfo;

	}
	
	/**************************** 队伍大小球 ****************************/
	private Playinfo parseBigsmallTeamPlayinfo(JSONArray lineArray,Integer[]  playindex,int gameTime,int playType,int marketID, String showior, String iorpoints) throws Exception{
		Playinfo playinfo = null;
		if(null == playindex) return null;
		// 主队大小球 大交易项
		String hostTradingItem = HttpUtil.getJsonArrayStringValue(lineArray,playindex);
		if(HttpUtil.isNull(hostTradingItem)) return playinfo;
		//  主队大小球 大赔率
		Double hostRation = HttpUtil.getJsonArrayDoubleShift(lineArray, playindex,2);

		// 主队大小球 小交易项
		String customerTradingItem = HttpUtil.getJsonArrayStringShift(lineArray,playindex,1);
		// 主队大小球 小赔率
		Double customerRation = HttpUtil.getJsonArrayDoubleShift(lineArray,playindex,3);
		
		String bigsmallRatioHost[] = HgUtil.get_other_ioratio(marketID, customerRation, hostRation, showior, iorpoints);

		if (!HttpUtil.isNull(hostTradingItem) && !HttpUtil.isNull(customerTradingItem)) {
			playinfo = getPlayinfo(playType, null, gameTime, Double.parseDouble(bigsmallRatioHost[1]), Double.parseDouble(bigsmallRatioHost[0]), 0, hostTradingItem, customerTradingItem, null, null);
		}
				
		return playinfo;

	}
	
	
	
	/**
	 * 获取赛事玩法类型
	 * @param matchName
	 * @param gameCode
	 * @return
	 * 
	 */
	//	1 全场 2上半场
	//	1 全场 2上半场      11 第1节  	12第2节  		13第3节	 	14第4节  								3下半  		5加时
	// 	1 全场 2上半场     11 首盘优胜者  	12次盘优胜者 	13第三盘优胜者 	14第四盘优胜者 	15第五盘优胜者 	4局数获胜者
	private int findGameTime(String matchName,String gameCode){
		int gametime = 0;
		if(SnatchConstant.BASKETBALL.equals(gameCode)){
			if(matchName.contains(HgConstant.PARENT_MATCH_FONT)){
				if(matchName.contains(HgConstant.BASKET_PLAY_GAME_TIME_ONE)){
					return 11;
				}else if(matchName.contains(HgConstant.BASKET_PLAY_GAME_TIME_TWO)){
					return 12;
				}else if(matchName.contains(HgConstant.BASKET_PLAY_GAME_TIME_THREE)){
					return 13;
				}else if(matchName.contains(HgConstant.BASKET_PLAY_GAME_TIME_FOUR)){
					return 14;
				}else if(matchName.contains(HgConstant.BASKET_PLAY_GAME_TIME_FIRST_HALF)){
					return 2;
				}else if(matchName.contains(HgConstant.BASKET_PLAY_GAME_TIME_SECOND_HALF)){
					return 3;
				}else if(matchName.contains(HgConstant.BASKET_PLAY_GAME_TIME_ET)){
					return 5;
				}
			}
		}else if(SnatchConstant.TENNIS.equals(gameCode)){
			if(matchName.contains(HgConstant.PARENT_MATCH_FONT)){
				if(matchName.contains(HgConstant.TENNIS_PLAY_GAME_TIME_ONE)){
					return 11;
				}else if(matchName.contains(HgConstant.TENNIS_PLAY_GAME_TIME_TWO)){
					return 12;
				}else if(matchName.contains(HgConstant.TENNIS_PLAY_GAME_TIME_THREE)){
					return 13;
				}else if(matchName.contains(HgConstant.TENNIS_PLAY_GAME_TIME_FOUR)){
					return 14;
				}else if(matchName.contains(HgConstant.TENNIS_PLAY_GAME_TIME_FIVE)){
					return 15;
				}else if(matchName.contains(HgConstant.TENNIS_PLAY_GAME_TIME_INNING)){
					return 4;
				}
			}
		}else if(SnatchConstant.VOLLEYBALL.equals(gameCode)){
			if(matchName.contains(HgConstant.PARENT_MATCH_FONT)){
				if(matchName.contains(HgConstant.VOLLEYBALL_PLAY_GAME_TIME_ONE)){
					return 11;
				}else if(matchName.contains(HgConstant.VOLLEYBALL_PLAY_GAME_TIME_TWO)){
					return 12;
				}else if(matchName.contains(HgConstant.VOLLEYBALL_PLAY_GAME_TIME_THREE)){
					return 13;
				}else if(matchName.contains(HgConstant.VOLLEYBALL_PLAY_GAME_TIME_FOUR)){
					return 14;
				}else if(matchName.contains(HgConstant.VOLLEYBALL_PLAY_GAME_TIME_FIVE)){
					return 15;
				}else if(matchName.contains(HgConstant.VOLLEYBALL_PLAY_GAME_TIME_SIX)){
					return 16;
				}else if(matchName.contains(HgConstant.VOLLEYBALL_PLAY_GAME_TIME_SIX)){
					return 17;
				}else if(matchName.contains(HgConstant.VOLLEYBALL_PLAY_GAME_TIME_INNING)){
					return 4;
				}
			}
		}
		return gametime;
	}
	
	

}
